@lightprotocol/compressed-token 0.1.3 → 0.3.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/LICENSE +674 -0
- package/README.md +1 -1
- package/dist/cjs/browser/index.cjs +1428 -488
- package/dist/cjs/browser/index.cjs.map +1 -1
- package/dist/cjs/node/index.cjs +1401 -786
- package/dist/cjs/node/index.cjs.map +1 -1
- package/dist/es/browser/index.js +1429 -489
- package/dist/es/browser/index.js.map +1 -1
- package/dist/types/index.d.ts +1175 -396
- package/package.json +116 -91
- package/dist/es/node/index.js +0 -4404
- package/dist/es/node/index.js.map +0 -1
package/dist/cjs/node/index.cjs
CHANGED
|
@@ -1,29 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var stateless_js = require('@lightprotocol/stateless.js');
|
|
4
|
-
var anchor = require('@coral-xyz/anchor');
|
|
5
4
|
var web3_js = require('@solana/web3.js');
|
|
5
|
+
var anchor = require('@coral-xyz/anchor');
|
|
6
6
|
var require$$0 = require('buffer');
|
|
7
|
-
var require$$0$2 = require('fs');
|
|
8
|
-
var require$$0$1 = require('path');
|
|
9
7
|
|
|
10
8
|
const IDL = {
|
|
11
|
-
version: '0.
|
|
9
|
+
version: '0.4.0',
|
|
12
10
|
name: 'light_compressed_token',
|
|
13
|
-
constants: [
|
|
14
|
-
{
|
|
15
|
-
name: 'PROGRAM_ID',
|
|
16
|
-
type: 'string',
|
|
17
|
-
value: '"9sixVEthz2kMSKfeApZXHwuboT6DZuT6crAYJTciUCqE"',
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
11
|
instructions: [
|
|
21
12
|
{
|
|
22
13
|
name: 'createMint',
|
|
23
14
|
docs: [
|
|
24
|
-
'This instruction expects a mint account to be created in a separate
|
|
25
|
-
'with token authority as mint authority.',
|
|
26
|
-
'
|
|
15
|
+
'This instruction expects a mint account to be created in a separate',
|
|
16
|
+
'token program instruction with token authority as mint authority. This',
|
|
17
|
+
'instruction creates a token pool account for that mint owned by token',
|
|
18
|
+
'authority.',
|
|
27
19
|
],
|
|
28
20
|
accounts: [
|
|
29
21
|
{
|
|
@@ -31,11 +23,6 @@ const IDL = {
|
|
|
31
23
|
isMut: true,
|
|
32
24
|
isSigner: true,
|
|
33
25
|
},
|
|
34
|
-
{
|
|
35
|
-
name: 'authority',
|
|
36
|
-
isMut: true,
|
|
37
|
-
isSigner: true,
|
|
38
|
-
},
|
|
39
26
|
{
|
|
40
27
|
name: 'tokenPoolPda',
|
|
41
28
|
isMut: true,
|
|
@@ -51,11 +38,6 @@ const IDL = {
|
|
|
51
38
|
isMut: true,
|
|
52
39
|
isSigner: false,
|
|
53
40
|
},
|
|
54
|
-
{
|
|
55
|
-
name: 'mintAuthorityPda',
|
|
56
|
-
isMut: true,
|
|
57
|
-
isSigner: false,
|
|
58
|
-
},
|
|
59
41
|
{
|
|
60
42
|
name: 'tokenProgram',
|
|
61
43
|
isMut: false,
|
|
@@ -71,6 +53,12 @@ const IDL = {
|
|
|
71
53
|
},
|
|
72
54
|
{
|
|
73
55
|
name: 'mintTo',
|
|
56
|
+
docs: [
|
|
57
|
+
'Mints tokens from an spl token mint to a list of compressed accounts.',
|
|
58
|
+
'Minted tokens are transferred to a pool account owned by the compressed',
|
|
59
|
+
'token program. The instruction creates one compressed output account for',
|
|
60
|
+
'every amount and pubkey input pair one output compressed account.',
|
|
61
|
+
],
|
|
74
62
|
accounts: [
|
|
75
63
|
{
|
|
76
64
|
name: 'feePayer',
|
|
@@ -79,12 +67,12 @@ const IDL = {
|
|
|
79
67
|
},
|
|
80
68
|
{
|
|
81
69
|
name: 'authority',
|
|
82
|
-
isMut:
|
|
70
|
+
isMut: false,
|
|
83
71
|
isSigner: true,
|
|
84
72
|
},
|
|
85
73
|
{
|
|
86
|
-
name: '
|
|
87
|
-
isMut:
|
|
74
|
+
name: 'cpiAuthorityPda',
|
|
75
|
+
isMut: false,
|
|
88
76
|
isSigner: false,
|
|
89
77
|
},
|
|
90
78
|
{
|
|
@@ -103,13 +91,13 @@ const IDL = {
|
|
|
103
91
|
isSigner: false,
|
|
104
92
|
},
|
|
105
93
|
{
|
|
106
|
-
name: '
|
|
94
|
+
name: 'lightSystemProgram',
|
|
107
95
|
isMut: false,
|
|
108
96
|
isSigner: false,
|
|
109
97
|
},
|
|
110
98
|
{
|
|
111
99
|
name: 'registeredProgramPda',
|
|
112
|
-
isMut:
|
|
100
|
+
isMut: false,
|
|
113
101
|
isSigner: false,
|
|
114
102
|
},
|
|
115
103
|
{
|
|
@@ -119,7 +107,7 @@ const IDL = {
|
|
|
119
107
|
},
|
|
120
108
|
{
|
|
121
109
|
name: 'accountCompressionAuthority',
|
|
122
|
-
isMut:
|
|
110
|
+
isMut: false,
|
|
123
111
|
isSigner: false,
|
|
124
112
|
},
|
|
125
113
|
{
|
|
@@ -137,6 +125,11 @@ const IDL = {
|
|
|
137
125
|
isMut: false,
|
|
138
126
|
isSigner: false,
|
|
139
127
|
},
|
|
128
|
+
{
|
|
129
|
+
name: 'systemProgram',
|
|
130
|
+
isMut: false,
|
|
131
|
+
isSigner: false,
|
|
132
|
+
},
|
|
140
133
|
],
|
|
141
134
|
args: [
|
|
142
135
|
{
|
|
@@ -146,19 +139,418 @@ const IDL = {
|
|
|
146
139
|
},
|
|
147
140
|
},
|
|
148
141
|
{
|
|
149
|
-
name: 'amounts',
|
|
150
|
-
type: {
|
|
151
|
-
vec: 'u64',
|
|
152
|
-
},
|
|
142
|
+
name: 'amounts',
|
|
143
|
+
type: {
|
|
144
|
+
vec: 'u64',
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: 'transfer',
|
|
151
|
+
accounts: [
|
|
152
|
+
{
|
|
153
|
+
name: 'feePayer',
|
|
154
|
+
isMut: true,
|
|
155
|
+
isSigner: true,
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
name: 'authority',
|
|
159
|
+
isMut: false,
|
|
160
|
+
isSigner: true,
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
name: 'cpiAuthorityPda',
|
|
164
|
+
isMut: false,
|
|
165
|
+
isSigner: false,
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: 'lightSystemProgram',
|
|
169
|
+
isMut: false,
|
|
170
|
+
isSigner: false,
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
name: 'registeredProgramPda',
|
|
174
|
+
isMut: false,
|
|
175
|
+
isSigner: false,
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: 'noopProgram',
|
|
179
|
+
isMut: false,
|
|
180
|
+
isSigner: false,
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: 'accountCompressionAuthority',
|
|
184
|
+
isMut: false,
|
|
185
|
+
isSigner: false,
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
name: 'accountCompressionProgram',
|
|
189
|
+
isMut: false,
|
|
190
|
+
isSigner: false,
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: 'selfProgram',
|
|
194
|
+
isMut: false,
|
|
195
|
+
isSigner: false,
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
name: 'tokenPoolPda',
|
|
199
|
+
isMut: true,
|
|
200
|
+
isSigner: false,
|
|
201
|
+
isOptional: true,
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
name: 'compressOrDecompressTokenAccount',
|
|
205
|
+
isMut: true,
|
|
206
|
+
isSigner: false,
|
|
207
|
+
isOptional: true,
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
name: 'tokenProgram',
|
|
211
|
+
isMut: false,
|
|
212
|
+
isSigner: false,
|
|
213
|
+
isOptional: true,
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
name: 'systemProgram',
|
|
217
|
+
isMut: false,
|
|
218
|
+
isSigner: false,
|
|
219
|
+
},
|
|
220
|
+
],
|
|
221
|
+
args: [
|
|
222
|
+
{
|
|
223
|
+
name: 'inputs',
|
|
224
|
+
type: 'bytes',
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
name: 'approve',
|
|
230
|
+
accounts: [
|
|
231
|
+
{
|
|
232
|
+
name: 'feePayer',
|
|
233
|
+
isMut: true,
|
|
234
|
+
isSigner: true,
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
name: 'authority',
|
|
238
|
+
isMut: false,
|
|
239
|
+
isSigner: true,
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
name: 'cpiAuthorityPda',
|
|
243
|
+
isMut: false,
|
|
244
|
+
isSigner: false,
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
name: 'lightSystemProgram',
|
|
248
|
+
isMut: false,
|
|
249
|
+
isSigner: false,
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
name: 'registeredProgramPda',
|
|
253
|
+
isMut: false,
|
|
254
|
+
isSigner: false,
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
name: 'noopProgram',
|
|
258
|
+
isMut: false,
|
|
259
|
+
isSigner: false,
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
name: 'accountCompressionAuthority',
|
|
263
|
+
isMut: false,
|
|
264
|
+
isSigner: false,
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
name: 'accountCompressionProgram',
|
|
268
|
+
isMut: false,
|
|
269
|
+
isSigner: false,
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
name: 'selfProgram',
|
|
273
|
+
isMut: false,
|
|
274
|
+
isSigner: false,
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
name: 'systemProgram',
|
|
278
|
+
isMut: false,
|
|
279
|
+
isSigner: false,
|
|
280
|
+
},
|
|
281
|
+
],
|
|
282
|
+
args: [
|
|
283
|
+
{
|
|
284
|
+
name: 'inputs',
|
|
285
|
+
type: 'bytes',
|
|
286
|
+
},
|
|
287
|
+
],
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
name: 'revoke',
|
|
291
|
+
accounts: [
|
|
292
|
+
{
|
|
293
|
+
name: 'feePayer',
|
|
294
|
+
isMut: true,
|
|
295
|
+
isSigner: true,
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
name: 'authority',
|
|
299
|
+
isMut: false,
|
|
300
|
+
isSigner: true,
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
name: 'cpiAuthorityPda',
|
|
304
|
+
isMut: false,
|
|
305
|
+
isSigner: false,
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
name: 'lightSystemProgram',
|
|
309
|
+
isMut: false,
|
|
310
|
+
isSigner: false,
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
name: 'registeredProgramPda',
|
|
314
|
+
isMut: false,
|
|
315
|
+
isSigner: false,
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
name: 'noopProgram',
|
|
319
|
+
isMut: false,
|
|
320
|
+
isSigner: false,
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
name: 'accountCompressionAuthority',
|
|
324
|
+
isMut: false,
|
|
325
|
+
isSigner: false,
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
name: 'accountCompressionProgram',
|
|
329
|
+
isMut: false,
|
|
330
|
+
isSigner: false,
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
name: 'selfProgram',
|
|
334
|
+
isMut: false,
|
|
335
|
+
isSigner: false,
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
name: 'systemProgram',
|
|
339
|
+
isMut: false,
|
|
340
|
+
isSigner: false,
|
|
341
|
+
},
|
|
342
|
+
],
|
|
343
|
+
args: [
|
|
344
|
+
{
|
|
345
|
+
name: 'inputs',
|
|
346
|
+
type: 'bytes',
|
|
347
|
+
},
|
|
348
|
+
],
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
name: 'freeze',
|
|
352
|
+
accounts: [
|
|
353
|
+
{
|
|
354
|
+
name: 'feePayer',
|
|
355
|
+
isMut: true,
|
|
356
|
+
isSigner: true,
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
name: 'authority',
|
|
360
|
+
isMut: false,
|
|
361
|
+
isSigner: true,
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
name: 'cpiAuthorityPda',
|
|
365
|
+
isMut: false,
|
|
366
|
+
isSigner: false,
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
name: 'lightSystemProgram',
|
|
370
|
+
isMut: false,
|
|
371
|
+
isSigner: false,
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
name: 'registeredProgramPda',
|
|
375
|
+
isMut: false,
|
|
376
|
+
isSigner: false,
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
name: 'noopProgram',
|
|
380
|
+
isMut: false,
|
|
381
|
+
isSigner: false,
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
name: 'accountCompressionAuthority',
|
|
385
|
+
isMut: false,
|
|
386
|
+
isSigner: false,
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
name: 'accountCompressionProgram',
|
|
390
|
+
isMut: false,
|
|
391
|
+
isSigner: false,
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
name: 'selfProgram',
|
|
395
|
+
isMut: false,
|
|
396
|
+
isSigner: false,
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
name: 'systemProgram',
|
|
400
|
+
isMut: false,
|
|
401
|
+
isSigner: false,
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
name: 'mint',
|
|
405
|
+
isMut: false,
|
|
406
|
+
isSigner: false,
|
|
407
|
+
},
|
|
408
|
+
],
|
|
409
|
+
args: [
|
|
410
|
+
{
|
|
411
|
+
name: 'inputs',
|
|
412
|
+
type: 'bytes',
|
|
413
|
+
},
|
|
414
|
+
],
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
name: 'thaw',
|
|
418
|
+
accounts: [
|
|
419
|
+
{
|
|
420
|
+
name: 'feePayer',
|
|
421
|
+
isMut: true,
|
|
422
|
+
isSigner: true,
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
name: 'authority',
|
|
426
|
+
isMut: false,
|
|
427
|
+
isSigner: true,
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
name: 'cpiAuthorityPda',
|
|
431
|
+
isMut: false,
|
|
432
|
+
isSigner: false,
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
name: 'lightSystemProgram',
|
|
436
|
+
isMut: false,
|
|
437
|
+
isSigner: false,
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
name: 'registeredProgramPda',
|
|
441
|
+
isMut: false,
|
|
442
|
+
isSigner: false,
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
name: 'noopProgram',
|
|
446
|
+
isMut: false,
|
|
447
|
+
isSigner: false,
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
name: 'accountCompressionAuthority',
|
|
451
|
+
isMut: false,
|
|
452
|
+
isSigner: false,
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
name: 'accountCompressionProgram',
|
|
456
|
+
isMut: false,
|
|
457
|
+
isSigner: false,
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
name: 'selfProgram',
|
|
461
|
+
isMut: false,
|
|
462
|
+
isSigner: false,
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
name: 'systemProgram',
|
|
466
|
+
isMut: false,
|
|
467
|
+
isSigner: false,
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
name: 'mint',
|
|
471
|
+
isMut: false,
|
|
472
|
+
isSigner: false,
|
|
473
|
+
},
|
|
474
|
+
],
|
|
475
|
+
args: [
|
|
476
|
+
{
|
|
477
|
+
name: 'inputs',
|
|
478
|
+
type: 'bytes',
|
|
479
|
+
},
|
|
480
|
+
],
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
name: 'burn',
|
|
484
|
+
accounts: [
|
|
485
|
+
{
|
|
486
|
+
name: 'feePayer',
|
|
487
|
+
isMut: true,
|
|
488
|
+
isSigner: true,
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
name: 'authority',
|
|
492
|
+
isMut: false,
|
|
493
|
+
isSigner: true,
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
name: 'cpiAuthorityPda',
|
|
497
|
+
isMut: false,
|
|
498
|
+
isSigner: false,
|
|
499
|
+
},
|
|
500
|
+
{
|
|
501
|
+
name: 'lightSystemProgram',
|
|
502
|
+
isMut: false,
|
|
503
|
+
isSigner: false,
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
name: 'registeredProgramPda',
|
|
507
|
+
isMut: false,
|
|
508
|
+
isSigner: false,
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
name: 'noopProgram',
|
|
512
|
+
isMut: false,
|
|
513
|
+
isSigner: false,
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
name: 'accountCompressionAuthority',
|
|
517
|
+
isMut: false,
|
|
518
|
+
isSigner: false,
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
name: 'accountCompressionProgram',
|
|
522
|
+
isMut: false,
|
|
523
|
+
isSigner: false,
|
|
524
|
+
},
|
|
525
|
+
{
|
|
526
|
+
name: 'selfProgram',
|
|
527
|
+
isMut: false,
|
|
528
|
+
isSigner: false,
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
name: 'systemProgram',
|
|
532
|
+
isMut: false,
|
|
533
|
+
isSigner: false,
|
|
534
|
+
},
|
|
535
|
+
],
|
|
536
|
+
args: [
|
|
537
|
+
{
|
|
538
|
+
name: 'inputs',
|
|
539
|
+
type: 'bytes',
|
|
153
540
|
},
|
|
154
541
|
],
|
|
155
542
|
},
|
|
156
543
|
{
|
|
157
|
-
name: '
|
|
544
|
+
name: 'stubIdlBuild',
|
|
545
|
+
docs: [
|
|
546
|
+
'This function is a stub to allow Anchor to include the input types in',
|
|
547
|
+
'the IDL. It should not be included in production builds nor be called in',
|
|
548
|
+
'practice.',
|
|
549
|
+
],
|
|
158
550
|
accounts: [
|
|
159
551
|
{
|
|
160
552
|
name: 'feePayer',
|
|
161
|
-
isMut:
|
|
553
|
+
isMut: true,
|
|
162
554
|
isSigner: true,
|
|
163
555
|
},
|
|
164
556
|
{
|
|
@@ -172,7 +564,7 @@ const IDL = {
|
|
|
172
564
|
isSigner: false,
|
|
173
565
|
},
|
|
174
566
|
{
|
|
175
|
-
name: '
|
|
567
|
+
name: 'lightSystemProgram',
|
|
176
568
|
isMut: false,
|
|
177
569
|
isSigner: false,
|
|
178
570
|
},
|
|
@@ -208,7 +600,7 @@ const IDL = {
|
|
|
208
600
|
isOptional: true,
|
|
209
601
|
},
|
|
210
602
|
{
|
|
211
|
-
name: '
|
|
603
|
+
name: 'compressOrDecompressTokenAccount',
|
|
212
604
|
isMut: true,
|
|
213
605
|
isSigner: false,
|
|
214
606
|
isOptional: true,
|
|
@@ -219,86 +611,77 @@ const IDL = {
|
|
|
219
611
|
isSigner: false,
|
|
220
612
|
isOptional: true,
|
|
221
613
|
},
|
|
614
|
+
{
|
|
615
|
+
name: 'systemProgram',
|
|
616
|
+
isMut: false,
|
|
617
|
+
isSigner: false,
|
|
618
|
+
},
|
|
222
619
|
],
|
|
223
620
|
args: [
|
|
224
621
|
{
|
|
225
|
-
name: '
|
|
226
|
-
type:
|
|
622
|
+
name: 'inputs1',
|
|
623
|
+
type: {
|
|
624
|
+
defined: 'CompressedTokenInstructionDataTransfer',
|
|
625
|
+
},
|
|
227
626
|
},
|
|
228
627
|
{
|
|
229
|
-
name: '
|
|
628
|
+
name: 'inputs2',
|
|
230
629
|
type: {
|
|
231
|
-
|
|
232
|
-
defined: 'CompressedCpiContext',
|
|
233
|
-
},
|
|
630
|
+
defined: 'TokenData',
|
|
234
631
|
},
|
|
235
632
|
},
|
|
236
633
|
],
|
|
237
634
|
},
|
|
238
635
|
],
|
|
239
|
-
|
|
636
|
+
accounts: [
|
|
240
637
|
{
|
|
241
|
-
name: '
|
|
638
|
+
name: 'RegisteredProgram',
|
|
242
639
|
type: {
|
|
243
640
|
kind: 'struct',
|
|
244
641
|
fields: [
|
|
245
642
|
{
|
|
246
|
-
name: '
|
|
247
|
-
type:
|
|
248
|
-
defined: 'CompressedAccount',
|
|
249
|
-
},
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
name: 'merkleTreePubkeyIndex',
|
|
253
|
-
type: 'u8',
|
|
254
|
-
},
|
|
255
|
-
{
|
|
256
|
-
name: 'nullifierQueuePubkeyIndex',
|
|
257
|
-
type: 'u8',
|
|
643
|
+
name: 'registeredProgramId',
|
|
644
|
+
type: 'publicKey',
|
|
258
645
|
},
|
|
259
646
|
{
|
|
260
|
-
name: '
|
|
261
|
-
type: '
|
|
647
|
+
name: 'groupAuthorityPda',
|
|
648
|
+
type: 'publicKey',
|
|
262
649
|
},
|
|
263
650
|
],
|
|
264
651
|
},
|
|
265
652
|
},
|
|
653
|
+
],
|
|
654
|
+
types: [
|
|
266
655
|
{
|
|
267
|
-
name: '
|
|
656
|
+
name: 'AccessMetadata',
|
|
268
657
|
type: {
|
|
269
658
|
kind: 'struct',
|
|
270
659
|
fields: [
|
|
271
660
|
{
|
|
272
|
-
name: '
|
|
661
|
+
name: 'owner',
|
|
662
|
+
docs: ['Owner of the Merkle tree.'],
|
|
273
663
|
type: 'publicKey',
|
|
274
664
|
},
|
|
275
665
|
{
|
|
276
|
-
name: '
|
|
666
|
+
name: 'programOwner',
|
|
667
|
+
docs: [
|
|
668
|
+
'Delegate of the Merkle tree. This will be used for program owned Merkle trees.',
|
|
669
|
+
],
|
|
277
670
|
type: 'publicKey',
|
|
278
671
|
},
|
|
279
|
-
{
|
|
280
|
-
name: 'leafIndex',
|
|
281
|
-
type: 'u32',
|
|
282
|
-
},
|
|
283
672
|
],
|
|
284
673
|
},
|
|
285
674
|
},
|
|
286
675
|
{
|
|
287
|
-
name: '
|
|
676
|
+
name: 'AccountState',
|
|
288
677
|
type: {
|
|
289
|
-
kind: '
|
|
290
|
-
|
|
291
|
-
{
|
|
292
|
-
name: 'merkleTreePubkeyIndex',
|
|
293
|
-
type: 'u8',
|
|
294
|
-
},
|
|
678
|
+
kind: 'enum',
|
|
679
|
+
variants: [
|
|
295
680
|
{
|
|
296
|
-
name: '
|
|
297
|
-
type: 'u8',
|
|
681
|
+
name: 'Initialized',
|
|
298
682
|
},
|
|
299
683
|
{
|
|
300
|
-
name: '
|
|
301
|
-
type: 'u32',
|
|
684
|
+
name: 'Frozen',
|
|
302
685
|
},
|
|
303
686
|
],
|
|
304
687
|
},
|
|
@@ -361,56 +744,81 @@ const IDL = {
|
|
|
361
744
|
},
|
|
362
745
|
{
|
|
363
746
|
name: 'CompressedCpiContext',
|
|
364
|
-
docs: ['To spend multiple compressed'],
|
|
365
747
|
type: {
|
|
366
748
|
kind: 'struct',
|
|
367
749
|
fields: [
|
|
368
750
|
{
|
|
369
|
-
name: '
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
751
|
+
name: 'setContext',
|
|
752
|
+
type: 'bool',
|
|
753
|
+
},
|
|
754
|
+
{
|
|
755
|
+
name: 'cpiContextAccountIndex',
|
|
374
756
|
type: 'u8',
|
|
375
757
|
},
|
|
758
|
+
],
|
|
759
|
+
},
|
|
760
|
+
},
|
|
761
|
+
{
|
|
762
|
+
name: 'CompressedProof',
|
|
763
|
+
type: {
|
|
764
|
+
kind: 'struct',
|
|
765
|
+
fields: [
|
|
766
|
+
{
|
|
767
|
+
name: 'a',
|
|
768
|
+
type: {
|
|
769
|
+
array: ['u8', 32],
|
|
770
|
+
},
|
|
771
|
+
},
|
|
376
772
|
{
|
|
377
|
-
name: '
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
773
|
+
name: 'b',
|
|
774
|
+
type: {
|
|
775
|
+
array: ['u8', 64],
|
|
776
|
+
},
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
name: 'c',
|
|
780
|
+
type: {
|
|
781
|
+
array: ['u8', 32],
|
|
782
|
+
},
|
|
384
783
|
},
|
|
385
784
|
],
|
|
386
785
|
},
|
|
387
786
|
},
|
|
388
787
|
{
|
|
389
|
-
name: '
|
|
788
|
+
name: 'CompressedTokenInstructionDataTransfer',
|
|
390
789
|
type: {
|
|
391
790
|
kind: 'struct',
|
|
392
791
|
fields: [
|
|
393
792
|
{
|
|
394
|
-
name: '
|
|
793
|
+
name: 'proof',
|
|
395
794
|
type: {
|
|
396
|
-
|
|
397
|
-
|
|
795
|
+
option: {
|
|
796
|
+
defined: 'CompressedProof',
|
|
398
797
|
},
|
|
399
798
|
},
|
|
400
799
|
},
|
|
401
800
|
{
|
|
402
|
-
name: '
|
|
801
|
+
name: 'mint',
|
|
802
|
+
type: 'publicKey',
|
|
803
|
+
},
|
|
804
|
+
{
|
|
805
|
+
name: 'delegatedTransfer',
|
|
806
|
+
docs: [
|
|
807
|
+
'If the signer is a delegate, the delegate index is index 0 of remaining accounts.',
|
|
808
|
+
'owner = Some(owner) is the owner of the token account.',
|
|
809
|
+
'Is set if the signer is delegate',
|
|
810
|
+
],
|
|
403
811
|
type: {
|
|
404
|
-
|
|
405
|
-
|
|
812
|
+
option: {
|
|
813
|
+
defined: 'DelegatedTransfer',
|
|
406
814
|
},
|
|
407
815
|
},
|
|
408
816
|
},
|
|
409
817
|
{
|
|
410
|
-
name: '
|
|
818
|
+
name: 'inputTokenDataWithContext',
|
|
411
819
|
type: {
|
|
412
820
|
vec: {
|
|
413
|
-
defined: '
|
|
821
|
+
defined: 'InputTokenDataWithContext',
|
|
414
822
|
},
|
|
415
823
|
},
|
|
416
824
|
},
|
|
@@ -418,53 +826,83 @@ const IDL = {
|
|
|
418
826
|
name: 'outputCompressedAccounts',
|
|
419
827
|
type: {
|
|
420
828
|
vec: {
|
|
421
|
-
defined: '
|
|
829
|
+
defined: 'PackedTokenTransferOutputData',
|
|
422
830
|
},
|
|
423
831
|
},
|
|
424
832
|
},
|
|
425
833
|
{
|
|
426
|
-
name: '
|
|
427
|
-
type: '
|
|
834
|
+
name: 'isCompress',
|
|
835
|
+
type: 'bool',
|
|
428
836
|
},
|
|
429
837
|
{
|
|
430
|
-
name: '
|
|
838
|
+
name: 'compressOrDecompressAmount',
|
|
431
839
|
type: {
|
|
432
|
-
|
|
840
|
+
option: 'u64',
|
|
433
841
|
},
|
|
434
842
|
},
|
|
435
843
|
{
|
|
436
|
-
name: '
|
|
844
|
+
name: 'cpiContext',
|
|
437
845
|
type: {
|
|
438
|
-
option:
|
|
846
|
+
option: {
|
|
847
|
+
defined: 'CompressedCpiContext',
|
|
848
|
+
},
|
|
439
849
|
},
|
|
440
850
|
},
|
|
851
|
+
],
|
|
852
|
+
},
|
|
853
|
+
},
|
|
854
|
+
{
|
|
855
|
+
name: 'DelegatedTransfer',
|
|
856
|
+
type: {
|
|
857
|
+
kind: 'struct',
|
|
858
|
+
fields: [
|
|
859
|
+
{
|
|
860
|
+
name: 'owner',
|
|
861
|
+
type: 'publicKey',
|
|
862
|
+
},
|
|
441
863
|
{
|
|
442
|
-
name: '
|
|
443
|
-
type: '
|
|
864
|
+
name: 'delegateChangeAccountIndex',
|
|
865
|
+
type: 'u8',
|
|
444
866
|
},
|
|
867
|
+
],
|
|
868
|
+
},
|
|
869
|
+
},
|
|
870
|
+
{
|
|
871
|
+
name: 'InputTokenDataWithContext',
|
|
872
|
+
type: {
|
|
873
|
+
kind: 'struct',
|
|
874
|
+
fields: [
|
|
445
875
|
{
|
|
446
|
-
name: '
|
|
876
|
+
name: 'amount',
|
|
877
|
+
type: 'u64',
|
|
878
|
+
},
|
|
879
|
+
{
|
|
880
|
+
name: 'delegateIndex',
|
|
447
881
|
type: {
|
|
448
|
-
option: '
|
|
882
|
+
option: 'u8',
|
|
449
883
|
},
|
|
450
884
|
},
|
|
451
885
|
{
|
|
452
|
-
name: '
|
|
886
|
+
name: 'isNative',
|
|
453
887
|
type: {
|
|
454
|
-
|
|
888
|
+
option: 'u64',
|
|
455
889
|
},
|
|
456
890
|
},
|
|
457
891
|
{
|
|
458
|
-
name: '
|
|
892
|
+
name: 'merkleContext',
|
|
459
893
|
type: {
|
|
460
|
-
|
|
894
|
+
defined: 'PackedMerkleContext',
|
|
461
895
|
},
|
|
462
896
|
},
|
|
897
|
+
{
|
|
898
|
+
name: 'rootIndex',
|
|
899
|
+
type: 'u16',
|
|
900
|
+
},
|
|
463
901
|
],
|
|
464
902
|
},
|
|
465
903
|
},
|
|
466
904
|
{
|
|
467
|
-
name: '
|
|
905
|
+
name: 'InstructionDataInvoke',
|
|
468
906
|
type: {
|
|
469
907
|
kind: 'struct',
|
|
470
908
|
fields: [
|
|
@@ -476,6 +914,28 @@ const IDL = {
|
|
|
476
914
|
},
|
|
477
915
|
},
|
|
478
916
|
},
|
|
917
|
+
{
|
|
918
|
+
name: 'inputCompressedAccountsWithMerkleContext',
|
|
919
|
+
type: {
|
|
920
|
+
vec: {
|
|
921
|
+
defined: 'PackedCompressedAccountWithMerkleContext',
|
|
922
|
+
},
|
|
923
|
+
},
|
|
924
|
+
},
|
|
925
|
+
{
|
|
926
|
+
name: 'outputCompressedAccounts',
|
|
927
|
+
type: {
|
|
928
|
+
vec: {
|
|
929
|
+
defined: 'OutputCompressedAccountWithPackedContext',
|
|
930
|
+
},
|
|
931
|
+
},
|
|
932
|
+
},
|
|
933
|
+
{
|
|
934
|
+
name: 'relayFee',
|
|
935
|
+
type: {
|
|
936
|
+
option: 'u64',
|
|
937
|
+
},
|
|
938
|
+
},
|
|
479
939
|
{
|
|
480
940
|
name: 'newAddressParams',
|
|
481
941
|
type: {
|
|
@@ -485,16 +945,44 @@ const IDL = {
|
|
|
485
945
|
},
|
|
486
946
|
},
|
|
487
947
|
{
|
|
488
|
-
name: '
|
|
948
|
+
name: 'compressOrDecompressLamports',
|
|
949
|
+
type: {
|
|
950
|
+
option: 'u64',
|
|
951
|
+
},
|
|
952
|
+
},
|
|
953
|
+
{
|
|
954
|
+
name: 'isCompress',
|
|
955
|
+
type: 'bool',
|
|
956
|
+
},
|
|
957
|
+
],
|
|
958
|
+
},
|
|
959
|
+
},
|
|
960
|
+
{
|
|
961
|
+
name: 'InstructionDataInvokeCpi',
|
|
962
|
+
type: {
|
|
963
|
+
kind: 'struct',
|
|
964
|
+
fields: [
|
|
965
|
+
{
|
|
966
|
+
name: 'proof',
|
|
967
|
+
type: {
|
|
968
|
+
option: {
|
|
969
|
+
defined: 'CompressedProof',
|
|
970
|
+
},
|
|
971
|
+
},
|
|
972
|
+
},
|
|
973
|
+
{
|
|
974
|
+
name: 'newAddressParams',
|
|
489
975
|
type: {
|
|
490
|
-
vec:
|
|
976
|
+
vec: {
|
|
977
|
+
defined: 'NewAddressParamsPacked',
|
|
978
|
+
},
|
|
491
979
|
},
|
|
492
980
|
},
|
|
493
981
|
{
|
|
494
982
|
name: 'inputCompressedAccountsWithMerkleContext',
|
|
495
983
|
type: {
|
|
496
984
|
vec: {
|
|
497
|
-
defined: '
|
|
985
|
+
defined: 'PackedCompressedAccountWithMerkleContext',
|
|
498
986
|
},
|
|
499
987
|
},
|
|
500
988
|
},
|
|
@@ -502,40 +990,83 @@ const IDL = {
|
|
|
502
990
|
name: 'outputCompressedAccounts',
|
|
503
991
|
type: {
|
|
504
992
|
vec: {
|
|
505
|
-
defined: '
|
|
993
|
+
defined: 'OutputCompressedAccountWithPackedContext',
|
|
506
994
|
},
|
|
507
995
|
},
|
|
508
996
|
},
|
|
509
997
|
{
|
|
510
|
-
name: '
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
type: 'bytes',
|
|
998
|
+
name: 'relayFee',
|
|
999
|
+
type: {
|
|
1000
|
+
option: 'u64',
|
|
1001
|
+
},
|
|
515
1002
|
},
|
|
516
1003
|
{
|
|
517
|
-
name: '
|
|
1004
|
+
name: 'compressOrDecompressLamports',
|
|
518
1005
|
type: {
|
|
519
1006
|
option: 'u64',
|
|
520
1007
|
},
|
|
521
1008
|
},
|
|
522
1009
|
{
|
|
523
|
-
name: '
|
|
524
|
-
type:
|
|
525
|
-
|
|
526
|
-
|
|
1010
|
+
name: 'isCompress',
|
|
1011
|
+
type: 'bool',
|
|
1012
|
+
},
|
|
1013
|
+
{
|
|
1014
|
+
name: 'signerSeeds',
|
|
1015
|
+
type: {
|
|
1016
|
+
vec: 'bytes',
|
|
1017
|
+
},
|
|
1018
|
+
},
|
|
1019
|
+
{
|
|
1020
|
+
name: 'cpiContext',
|
|
1021
|
+
type: {
|
|
1022
|
+
option: {
|
|
1023
|
+
defined: 'CompressedCpiContext',
|
|
1024
|
+
},
|
|
1025
|
+
},
|
|
1026
|
+
},
|
|
1027
|
+
],
|
|
1028
|
+
},
|
|
1029
|
+
},
|
|
1030
|
+
{
|
|
1031
|
+
name: 'MerkleTreeMetadata',
|
|
1032
|
+
type: {
|
|
1033
|
+
kind: 'struct',
|
|
1034
|
+
fields: [
|
|
1035
|
+
{
|
|
1036
|
+
name: 'accessMetadata',
|
|
1037
|
+
type: {
|
|
1038
|
+
defined: 'AccessMetadata',
|
|
1039
|
+
},
|
|
1040
|
+
},
|
|
1041
|
+
{
|
|
1042
|
+
name: 'rolloverMetadata',
|
|
1043
|
+
type: {
|
|
1044
|
+
defined: 'RolloverMetadata',
|
|
1045
|
+
},
|
|
1046
|
+
},
|
|
1047
|
+
{
|
|
1048
|
+
name: 'associatedQueue',
|
|
1049
|
+
type: 'publicKey',
|
|
1050
|
+
},
|
|
1051
|
+
{
|
|
1052
|
+
name: 'nextMerkleTree',
|
|
1053
|
+
type: 'publicKey',
|
|
527
1054
|
},
|
|
1055
|
+
],
|
|
1056
|
+
},
|
|
1057
|
+
},
|
|
1058
|
+
{
|
|
1059
|
+
name: 'MerkleTreeSequenceNumber',
|
|
1060
|
+
type: {
|
|
1061
|
+
kind: 'struct',
|
|
1062
|
+
fields: [
|
|
528
1063
|
{
|
|
529
|
-
name: '
|
|
530
|
-
type: '
|
|
1064
|
+
name: 'pubkey',
|
|
1065
|
+
type: 'publicKey',
|
|
531
1066
|
},
|
|
532
1067
|
{
|
|
533
|
-
name: '
|
|
534
|
-
type:
|
|
535
|
-
option: {
|
|
536
|
-
vec: 'bytes',
|
|
537
|
-
},
|
|
538
|
-
},
|
|
1068
|
+
name: 'seq',
|
|
1069
|
+
type: 'u64',
|
|
539
1070
|
},
|
|
540
1071
|
],
|
|
541
1072
|
},
|
|
@@ -567,84 +1098,55 @@ const IDL = {
|
|
|
567
1098
|
},
|
|
568
1099
|
},
|
|
569
1100
|
{
|
|
570
|
-
name: '
|
|
1101
|
+
name: 'OutputCompressedAccountWithPackedContext',
|
|
571
1102
|
type: {
|
|
572
1103
|
kind: 'struct',
|
|
573
1104
|
fields: [
|
|
574
1105
|
{
|
|
575
|
-
name: '
|
|
1106
|
+
name: 'compressedAccount',
|
|
576
1107
|
type: {
|
|
577
|
-
|
|
1108
|
+
defined: 'CompressedAccount',
|
|
578
1109
|
},
|
|
579
1110
|
},
|
|
580
1111
|
{
|
|
581
|
-
name: '
|
|
582
|
-
type: '
|
|
583
|
-
},
|
|
584
|
-
{
|
|
585
|
-
name: 'addressMerkleTreePubkey',
|
|
586
|
-
type: 'publicKey',
|
|
587
|
-
},
|
|
588
|
-
{
|
|
589
|
-
name: 'addressMerkleTreeRootIndex',
|
|
590
|
-
type: 'u16',
|
|
1112
|
+
name: 'merkleTreeIndex',
|
|
1113
|
+
type: 'u8',
|
|
591
1114
|
},
|
|
592
1115
|
],
|
|
593
1116
|
},
|
|
594
1117
|
},
|
|
595
1118
|
{
|
|
596
|
-
name: '
|
|
1119
|
+
name: 'PackedCompressedAccountWithMerkleContext',
|
|
597
1120
|
type: {
|
|
598
1121
|
kind: 'struct',
|
|
599
1122
|
fields: [
|
|
600
1123
|
{
|
|
601
|
-
name: '
|
|
1124
|
+
name: 'compressedAccount',
|
|
602
1125
|
type: {
|
|
603
|
-
|
|
1126
|
+
defined: 'CompressedAccount',
|
|
604
1127
|
},
|
|
605
1128
|
},
|
|
606
1129
|
{
|
|
607
|
-
name: '
|
|
1130
|
+
name: 'merkleContext',
|
|
608
1131
|
type: {
|
|
609
|
-
|
|
1132
|
+
defined: 'PackedMerkleContext',
|
|
610
1133
|
},
|
|
611
1134
|
},
|
|
612
1135
|
{
|
|
613
|
-
name: '
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
1136
|
+
name: 'rootIndex',
|
|
1137
|
+
docs: [
|
|
1138
|
+
'Index of root used in inclusion validity proof.',
|
|
1139
|
+
],
|
|
1140
|
+
type: 'u16',
|
|
617
1141
|
},
|
|
618
1142
|
],
|
|
619
1143
|
},
|
|
620
1144
|
},
|
|
621
1145
|
{
|
|
622
|
-
name: '
|
|
1146
|
+
name: 'PackedMerkleContext',
|
|
623
1147
|
type: {
|
|
624
1148
|
kind: 'struct',
|
|
625
1149
|
fields: [
|
|
626
|
-
{
|
|
627
|
-
name: 'amount',
|
|
628
|
-
type: 'u64',
|
|
629
|
-
},
|
|
630
|
-
{
|
|
631
|
-
name: 'delegateIndex',
|
|
632
|
-
type: {
|
|
633
|
-
option: 'u8',
|
|
634
|
-
},
|
|
635
|
-
},
|
|
636
|
-
{
|
|
637
|
-
name: 'delegatedAmount',
|
|
638
|
-
type: {
|
|
639
|
-
option: 'u64',
|
|
640
|
-
},
|
|
641
|
-
},
|
|
642
|
-
{
|
|
643
|
-
name: 'isNative',
|
|
644
|
-
type: {
|
|
645
|
-
option: 'u64',
|
|
646
|
-
},
|
|
647
|
-
},
|
|
648
1150
|
{
|
|
649
1151
|
name: 'merkleTreePubkeyIndex',
|
|
650
1152
|
type: 'u8',
|
|
@@ -661,37 +1163,49 @@ const IDL = {
|
|
|
661
1163
|
},
|
|
662
1164
|
},
|
|
663
1165
|
{
|
|
664
|
-
name: '
|
|
1166
|
+
name: 'PackedTokenTransferOutputData',
|
|
665
1167
|
type: {
|
|
666
1168
|
kind: 'struct',
|
|
667
1169
|
fields: [
|
|
668
1170
|
{
|
|
669
|
-
name: '
|
|
670
|
-
type:
|
|
671
|
-
option: {
|
|
672
|
-
defined: 'CompressedProof',
|
|
673
|
-
},
|
|
674
|
-
},
|
|
1171
|
+
name: 'owner',
|
|
1172
|
+
type: 'publicKey',
|
|
675
1173
|
},
|
|
676
1174
|
{
|
|
677
|
-
name: '
|
|
1175
|
+
name: 'amount',
|
|
1176
|
+
type: 'u64',
|
|
1177
|
+
},
|
|
1178
|
+
{
|
|
1179
|
+
name: 'lamports',
|
|
678
1180
|
type: {
|
|
679
|
-
|
|
1181
|
+
option: 'u64',
|
|
680
1182
|
},
|
|
681
1183
|
},
|
|
682
1184
|
{
|
|
683
|
-
name: '
|
|
684
|
-
type: '
|
|
1185
|
+
name: 'merkleTreeIndex',
|
|
1186
|
+
type: 'u8',
|
|
685
1187
|
},
|
|
1188
|
+
],
|
|
1189
|
+
},
|
|
1190
|
+
},
|
|
1191
|
+
{
|
|
1192
|
+
name: 'PublicTransactionEvent',
|
|
1193
|
+
type: {
|
|
1194
|
+
kind: 'struct',
|
|
1195
|
+
fields: [
|
|
686
1196
|
{
|
|
687
|
-
name: '
|
|
688
|
-
type:
|
|
1197
|
+
name: 'inputCompressedAccountHashes',
|
|
1198
|
+
type: {
|
|
1199
|
+
vec: {
|
|
1200
|
+
array: ['u8', 32],
|
|
1201
|
+
},
|
|
1202
|
+
},
|
|
689
1203
|
},
|
|
690
1204
|
{
|
|
691
|
-
name: '
|
|
1205
|
+
name: 'outputCompressedAccountHashes',
|
|
692
1206
|
type: {
|
|
693
1207
|
vec: {
|
|
694
|
-
|
|
1208
|
+
array: ['u8', 32],
|
|
695
1209
|
},
|
|
696
1210
|
},
|
|
697
1211
|
},
|
|
@@ -699,108 +1213,106 @@ const IDL = {
|
|
|
699
1213
|
name: 'outputCompressedAccounts',
|
|
700
1214
|
type: {
|
|
701
1215
|
vec: {
|
|
702
|
-
defined: '
|
|
1216
|
+
defined: 'OutputCompressedAccountWithPackedContext',
|
|
703
1217
|
},
|
|
704
1218
|
},
|
|
705
1219
|
},
|
|
706
1220
|
{
|
|
707
|
-
name: '
|
|
708
|
-
type:
|
|
1221
|
+
name: 'outputLeafIndices',
|
|
1222
|
+
type: {
|
|
1223
|
+
vec: 'u32',
|
|
1224
|
+
},
|
|
709
1225
|
},
|
|
710
1226
|
{
|
|
711
|
-
name: '
|
|
712
|
-
type:
|
|
1227
|
+
name: 'sequenceNumbers',
|
|
1228
|
+
type: {
|
|
1229
|
+
vec: {
|
|
1230
|
+
defined: 'MerkleTreeSequenceNumber',
|
|
1231
|
+
},
|
|
1232
|
+
},
|
|
713
1233
|
},
|
|
714
1234
|
{
|
|
715
|
-
name: '
|
|
1235
|
+
name: 'relayFee',
|
|
716
1236
|
type: {
|
|
717
1237
|
option: 'u64',
|
|
718
1238
|
},
|
|
719
1239
|
},
|
|
720
|
-
],
|
|
721
|
-
},
|
|
722
|
-
},
|
|
723
|
-
{
|
|
724
|
-
name: 'TokenTransferOutputData',
|
|
725
|
-
type: {
|
|
726
|
-
kind: 'struct',
|
|
727
|
-
fields: [
|
|
728
1240
|
{
|
|
729
|
-
name: '
|
|
730
|
-
type: '
|
|
1241
|
+
name: 'isCompress',
|
|
1242
|
+
type: 'bool',
|
|
731
1243
|
},
|
|
732
1244
|
{
|
|
733
|
-
name: '
|
|
734
|
-
type:
|
|
1245
|
+
name: 'compressOrDecompressLamports',
|
|
1246
|
+
type: {
|
|
1247
|
+
option: 'u64',
|
|
1248
|
+
},
|
|
735
1249
|
},
|
|
736
1250
|
{
|
|
737
|
-
name: '
|
|
1251
|
+
name: 'pubkeyArray',
|
|
738
1252
|
type: {
|
|
739
|
-
|
|
1253
|
+
vec: 'publicKey',
|
|
1254
|
+
},
|
|
1255
|
+
},
|
|
1256
|
+
{
|
|
1257
|
+
name: 'message',
|
|
1258
|
+
type: {
|
|
1259
|
+
option: 'bytes',
|
|
740
1260
|
},
|
|
741
1261
|
},
|
|
742
1262
|
],
|
|
743
1263
|
},
|
|
744
1264
|
},
|
|
745
1265
|
{
|
|
746
|
-
name: '
|
|
1266
|
+
name: 'RolloverMetadata',
|
|
747
1267
|
type: {
|
|
748
1268
|
kind: 'struct',
|
|
749
1269
|
fields: [
|
|
750
1270
|
{
|
|
751
|
-
name: '
|
|
752
|
-
docs: ['
|
|
753
|
-
type: '
|
|
754
|
-
},
|
|
755
|
-
{
|
|
756
|
-
name: 'owner',
|
|
757
|
-
docs: ['The owner of this account.'],
|
|
758
|
-
type: 'publicKey',
|
|
1271
|
+
name: 'index',
|
|
1272
|
+
docs: ['Unique index.'],
|
|
1273
|
+
type: 'u64',
|
|
759
1274
|
},
|
|
760
1275
|
{
|
|
761
|
-
name: '
|
|
762
|
-
docs: [
|
|
1276
|
+
name: 'rolloverFee',
|
|
1277
|
+
docs: [
|
|
1278
|
+
'This fee is used for rent for the next account.',
|
|
1279
|
+
'It accumulates in the account so that once the corresponding Merkle tree account is full it can be rolled over',
|
|
1280
|
+
],
|
|
763
1281
|
type: 'u64',
|
|
764
1282
|
},
|
|
765
1283
|
{
|
|
766
|
-
name: '
|
|
1284
|
+
name: 'rolloverThreshold',
|
|
767
1285
|
docs: [
|
|
768
|
-
'
|
|
769
|
-
'the amount authorized by the delegate',
|
|
1286
|
+
'The threshold in percentage points when the account should be rolled over (95 corresponds to 95% filled).',
|
|
770
1287
|
],
|
|
771
|
-
type:
|
|
772
|
-
option: 'publicKey',
|
|
773
|
-
},
|
|
1288
|
+
type: 'u64',
|
|
774
1289
|
},
|
|
775
1290
|
{
|
|
776
|
-
name: '
|
|
777
|
-
docs: [
|
|
778
|
-
type:
|
|
779
|
-
defined: 'AccountState',
|
|
780
|
-
},
|
|
1291
|
+
name: 'networkFee',
|
|
1292
|
+
docs: ['Tip for maintaining the account.'],
|
|
1293
|
+
type: 'u64',
|
|
781
1294
|
},
|
|
782
1295
|
{
|
|
783
|
-
name: '
|
|
1296
|
+
name: 'rolledoverSlot',
|
|
784
1297
|
docs: [
|
|
785
|
-
'
|
|
786
|
-
'reserve. An Account is required to be rent-exempt, so the value is',
|
|
787
|
-
'used by the Processor to ensure that wrapped SOL accounts do not',
|
|
788
|
-
'drop below this threshold.',
|
|
1298
|
+
'The slot when the account was rolled over, a rolled over account should not be written to.',
|
|
789
1299
|
],
|
|
790
|
-
type:
|
|
791
|
-
option: 'u64',
|
|
792
|
-
},
|
|
1300
|
+
type: 'u64',
|
|
793
1301
|
},
|
|
794
1302
|
{
|
|
795
|
-
name: '
|
|
796
|
-
docs: [
|
|
1303
|
+
name: 'closeThreshold',
|
|
1304
|
+
docs: [
|
|
1305
|
+
'If current slot is greater than rolledover_slot + close_threshold and',
|
|
1306
|
+
"the account is empty it can be closed. No 'close' functionality has been",
|
|
1307
|
+
'implemented yet.',
|
|
1308
|
+
],
|
|
797
1309
|
type: 'u64',
|
|
798
1310
|
},
|
|
799
1311
|
],
|
|
800
1312
|
},
|
|
801
1313
|
},
|
|
802
1314
|
{
|
|
803
|
-
name: '
|
|
1315
|
+
name: 'TokenData',
|
|
804
1316
|
type: {
|
|
805
1317
|
kind: 'struct',
|
|
806
1318
|
fields: [
|
|
@@ -832,7 +1344,9 @@ const IDL = {
|
|
|
832
1344
|
{
|
|
833
1345
|
name: 'state',
|
|
834
1346
|
docs: ["The account's state"],
|
|
835
|
-
type:
|
|
1347
|
+
type: {
|
|
1348
|
+
defined: 'AccountState',
|
|
1349
|
+
},
|
|
836
1350
|
},
|
|
837
1351
|
{
|
|
838
1352
|
name: 'isNative',
|
|
@@ -846,95 +1360,115 @@ const IDL = {
|
|
|
846
1360
|
option: 'u64',
|
|
847
1361
|
},
|
|
848
1362
|
},
|
|
849
|
-
{
|
|
850
|
-
name: 'delegatedAmount',
|
|
851
|
-
docs: ['The amount delegated'],
|
|
852
|
-
type: 'u64',
|
|
853
|
-
},
|
|
854
1363
|
],
|
|
855
1364
|
},
|
|
856
1365
|
},
|
|
1366
|
+
],
|
|
1367
|
+
errors: [
|
|
857
1368
|
{
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
variants: [
|
|
862
|
-
{
|
|
863
|
-
name: 'Uninitialized',
|
|
864
|
-
},
|
|
865
|
-
{
|
|
866
|
-
name: 'Initialized',
|
|
867
|
-
},
|
|
868
|
-
{
|
|
869
|
-
name: 'Frozen',
|
|
870
|
-
},
|
|
871
|
-
],
|
|
872
|
-
},
|
|
1369
|
+
code: 6000,
|
|
1370
|
+
name: 'PublicKeyAmountMissmatch',
|
|
1371
|
+
msg: 'public keys and amounts must be of same length',
|
|
873
1372
|
},
|
|
874
1373
|
{
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
{
|
|
904
|
-
name: 'SumCheckFailed',
|
|
905
|
-
},
|
|
906
|
-
{
|
|
907
|
-
name: 'DecompressRecipientUndefinedForDecompress',
|
|
908
|
-
},
|
|
909
|
-
{
|
|
910
|
-
name: 'CompressedPdaUndefinedForDecompress',
|
|
911
|
-
},
|
|
912
|
-
{
|
|
913
|
-
name: 'DeCompressAmountUndefinedForDecompress',
|
|
914
|
-
},
|
|
915
|
-
{
|
|
916
|
-
name: 'CompressedPdaUndefinedForCompress',
|
|
917
|
-
},
|
|
918
|
-
{
|
|
919
|
-
name: 'DeCompressAmountUndefinedForCompress',
|
|
920
|
-
},
|
|
921
|
-
{
|
|
922
|
-
name: 'DelegateUndefined',
|
|
923
|
-
},
|
|
924
|
-
],
|
|
925
|
-
},
|
|
1374
|
+
code: 6001,
|
|
1375
|
+
name: 'SignerCheckFailed',
|
|
1376
|
+
msg: 'SignerCheckFailed',
|
|
1377
|
+
},
|
|
1378
|
+
{
|
|
1379
|
+
code: 6002,
|
|
1380
|
+
name: 'ComputeInputSumFailed',
|
|
1381
|
+
msg: 'ComputeInputSumFailed',
|
|
1382
|
+
},
|
|
1383
|
+
{
|
|
1384
|
+
code: 6003,
|
|
1385
|
+
name: 'ComputeOutputSumFailed',
|
|
1386
|
+
msg: 'ComputeOutputSumFailed',
|
|
1387
|
+
},
|
|
1388
|
+
{
|
|
1389
|
+
code: 6004,
|
|
1390
|
+
name: 'ComputeCompressSumFailed',
|
|
1391
|
+
msg: 'ComputeCompressSumFailed',
|
|
1392
|
+
},
|
|
1393
|
+
{
|
|
1394
|
+
code: 6005,
|
|
1395
|
+
name: 'ComputeDecompressSumFailed',
|
|
1396
|
+
msg: 'ComputeDecompressSumFailed',
|
|
1397
|
+
},
|
|
1398
|
+
{
|
|
1399
|
+
code: 6006,
|
|
1400
|
+
name: 'SumCheckFailed',
|
|
1401
|
+
msg: 'SumCheckFailed',
|
|
926
1402
|
},
|
|
927
|
-
],
|
|
928
|
-
errors: [
|
|
929
1403
|
{
|
|
930
|
-
code:
|
|
931
|
-
name: '
|
|
932
|
-
msg: '
|
|
1404
|
+
code: 6007,
|
|
1405
|
+
name: 'DecompressRecipientUndefinedForDecompress',
|
|
1406
|
+
msg: 'DecompressRecipientUndefinedForDecompress',
|
|
933
1407
|
},
|
|
934
1408
|
{
|
|
935
|
-
code:
|
|
936
|
-
name: '
|
|
937
|
-
msg: '
|
|
1409
|
+
code: 6008,
|
|
1410
|
+
name: 'CompressedPdaUndefinedForDecompress',
|
|
1411
|
+
msg: 'CompressedPdaUndefinedForDecompress',
|
|
1412
|
+
},
|
|
1413
|
+
{
|
|
1414
|
+
code: 6009,
|
|
1415
|
+
name: 'DeCompressAmountUndefinedForDecompress',
|
|
1416
|
+
msg: 'DeCompressAmountUndefinedForDecompress',
|
|
1417
|
+
},
|
|
1418
|
+
{
|
|
1419
|
+
code: 6010,
|
|
1420
|
+
name: 'CompressedPdaUndefinedForCompress',
|
|
1421
|
+
msg: 'CompressedPdaUndefinedForCompress',
|
|
1422
|
+
},
|
|
1423
|
+
{
|
|
1424
|
+
code: 6011,
|
|
1425
|
+
name: 'DeCompressAmountUndefinedForCompress',
|
|
1426
|
+
msg: 'DeCompressAmountUndefinedForCompress',
|
|
1427
|
+
},
|
|
1428
|
+
{
|
|
1429
|
+
code: 6012,
|
|
1430
|
+
name: 'DelegateUndefined',
|
|
1431
|
+
msg: 'DelegateUndefined while delegated amount is defined',
|
|
1432
|
+
},
|
|
1433
|
+
{
|
|
1434
|
+
code: 6013,
|
|
1435
|
+
name: 'DelegateSignerCheckFailed',
|
|
1436
|
+
msg: 'DelegateSignerCheckFailed',
|
|
1437
|
+
},
|
|
1438
|
+
{
|
|
1439
|
+
code: 6014,
|
|
1440
|
+
name: 'SplTokenSupplyMismatch',
|
|
1441
|
+
msg: 'SplTokenSupplyMismatch',
|
|
1442
|
+
},
|
|
1443
|
+
{
|
|
1444
|
+
code: 6015,
|
|
1445
|
+
name: 'HeapMemoryCheckFailed',
|
|
1446
|
+
msg: 'HeapMemoryCheckFailed',
|
|
1447
|
+
},
|
|
1448
|
+
{
|
|
1449
|
+
code: 6016,
|
|
1450
|
+
name: 'InstructionNotCallable',
|
|
1451
|
+
msg: 'The instruction is not callable',
|
|
1452
|
+
},
|
|
1453
|
+
{
|
|
1454
|
+
code: 6017,
|
|
1455
|
+
name: 'ArithmeticUnderflow',
|
|
1456
|
+
msg: 'ArithmeticUnderflow',
|
|
1457
|
+
},
|
|
1458
|
+
{
|
|
1459
|
+
code: 6018,
|
|
1460
|
+
name: 'InvalidDelegate',
|
|
1461
|
+
msg: 'InvalidDelegate',
|
|
1462
|
+
},
|
|
1463
|
+
{
|
|
1464
|
+
code: 6019,
|
|
1465
|
+
name: 'HashToFieldError',
|
|
1466
|
+
msg: 'HashToFieldError',
|
|
1467
|
+
},
|
|
1468
|
+
{
|
|
1469
|
+
code: 6020,
|
|
1470
|
+
name: 'InvalidMint',
|
|
1471
|
+
msg: 'InvalidMint',
|
|
938
1472
|
},
|
|
939
1473
|
],
|
|
940
1474
|
};
|
|
@@ -944,7 +1478,7 @@ const IDL = {
|
|
|
944
1478
|
* Packs Compressed Token Accounts.
|
|
945
1479
|
*/
|
|
946
1480
|
function packCompressedTokenAccounts(params) {
|
|
947
|
-
const { inputCompressedTokenAccounts,
|
|
1481
|
+
const { inputCompressedTokenAccounts, outputStateTrees, remainingAccounts = [], rootIndices, tokenTransferOutputs, } = params;
|
|
948
1482
|
const _remainingAccounts = remainingAccounts.slice();
|
|
949
1483
|
let delegateIndex = null;
|
|
950
1484
|
if (inputCompressedTokenAccounts.length > 0 &&
|
|
@@ -955,27 +1489,35 @@ function packCompressedTokenAccounts(params) {
|
|
|
955
1489
|
/// Currently just packs 'delegate' to pubkeyArray
|
|
956
1490
|
const packedInputTokenData = [];
|
|
957
1491
|
/// pack inputs
|
|
958
|
-
inputCompressedTokenAccounts.forEach((account) => {
|
|
1492
|
+
inputCompressedTokenAccounts.forEach((account, index) => {
|
|
959
1493
|
const merkleTreePubkeyIndex = stateless_js.getIndexOrAdd(_remainingAccounts, account.compressedAccount.merkleTree);
|
|
960
1494
|
const nullifierQueuePubkeyIndex = stateless_js.getIndexOrAdd(_remainingAccounts, account.compressedAccount.nullifierQueue);
|
|
961
1495
|
packedInputTokenData.push({
|
|
962
1496
|
amount: account.parsed.amount,
|
|
963
1497
|
delegateIndex,
|
|
964
|
-
delegatedAmount: account.parsed.delegatedAmount.eq(stateless_js.bn(0))
|
|
965
|
-
? null
|
|
966
|
-
: account.parsed.delegatedAmount,
|
|
967
1498
|
isNative: account.parsed.isNative,
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
1499
|
+
merkleContext: {
|
|
1500
|
+
merkleTreePubkeyIndex,
|
|
1501
|
+
nullifierQueuePubkeyIndex,
|
|
1502
|
+
leafIndex: account.compressedAccount.leafIndex,
|
|
1503
|
+
},
|
|
1504
|
+
rootIndex: rootIndices[index],
|
|
971
1505
|
});
|
|
972
1506
|
});
|
|
973
1507
|
/// pack output state trees
|
|
974
|
-
const paddedOutputStateMerkleTrees = stateless_js.padOutputStateMerkleTrees(outputStateTrees,
|
|
975
|
-
const
|
|
976
|
-
paddedOutputStateMerkleTrees.forEach(account => {
|
|
977
|
-
|
|
978
|
-
|
|
1508
|
+
const paddedOutputStateMerkleTrees = stateless_js.padOutputStateMerkleTrees(outputStateTrees, tokenTransferOutputs.length, inputCompressedTokenAccounts.map(acc => acc.compressedAccount));
|
|
1509
|
+
const packedOutputTokenData = [];
|
|
1510
|
+
paddedOutputStateMerkleTrees.forEach((account, index) => {
|
|
1511
|
+
var _a;
|
|
1512
|
+
const merkleTreeIndex = stateless_js.getIndexOrAdd(_remainingAccounts, account);
|
|
1513
|
+
packedOutputTokenData.push({
|
|
1514
|
+
owner: tokenTransferOutputs[index].owner,
|
|
1515
|
+
amount: tokenTransferOutputs[index].amount,
|
|
1516
|
+
lamports: ((_a = tokenTransferOutputs[index].lamports) === null || _a === void 0 ? void 0 : _a.eq(stateless_js.bn(0)))
|
|
1517
|
+
? null
|
|
1518
|
+
: tokenTransferOutputs[index].lamports,
|
|
1519
|
+
merkleTreeIndex,
|
|
1520
|
+
});
|
|
979
1521
|
});
|
|
980
1522
|
// to meta
|
|
981
1523
|
const remainingAccountMetas = _remainingAccounts.map((account) => ({
|
|
@@ -985,14 +1527,13 @@ function packCompressedTokenAccounts(params) {
|
|
|
985
1527
|
}));
|
|
986
1528
|
return {
|
|
987
1529
|
inputTokenDataWithContext: packedInputTokenData,
|
|
988
|
-
outputStateMerkleTreeIndices,
|
|
989
1530
|
remainingAccountMetas,
|
|
1531
|
+
packedOutputTokenData,
|
|
990
1532
|
};
|
|
991
1533
|
}
|
|
992
1534
|
|
|
993
1535
|
const POOL_SEED = Buffer.from('pool');
|
|
994
1536
|
const CPI_AUTHORITY_SEED = Buffer.from('cpi_authority');
|
|
995
|
-
const MINT_AUTHORITY_SEED = anchor.utils.bytes.utf8.encode('mint_authority_pda');
|
|
996
1537
|
const SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE = 1461600;
|
|
997
1538
|
|
|
998
1539
|
/** Address of the SPL Token program */
|
|
@@ -1000,7 +1541,7 @@ const TOKEN_PROGRAM_ID = new web3_js.PublicKey('TokenkegQfeZyiNwAJbNbGKPFXCWuBvf
|
|
|
1000
1541
|
/** Address of the SPL Token 2022 program */
|
|
1001
1542
|
new web3_js.PublicKey('TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb');
|
|
1002
1543
|
/** Address of the SPL Associated Token Account program */
|
|
1003
|
-
new web3_js.PublicKey('ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL');
|
|
1544
|
+
const ASSOCIATED_TOKEN_PROGRAM_ID = new web3_js.PublicKey('ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL');
|
|
1004
1545
|
/** Address of the special mint for wrapped native SOL in spl-token */
|
|
1005
1546
|
new web3_js.PublicKey('So11111111111111111111111111111111111111112');
|
|
1006
1547
|
/** Address of the special mint for wrapped native SOL in spl-token-2022 */
|
|
@@ -3295,334 +3836,16 @@ const encodeDecode = (layout) => {
|
|
|
3295
3836
|
return { decode, encode };
|
|
3296
3837
|
};
|
|
3297
3838
|
|
|
3298
|
-
var
|
|
3299
|
-
|
|
3300
|
-
function commonjsRequire(path) {
|
|
3301
|
-
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
3302
|
-
}
|
|
3303
|
-
|
|
3304
|
-
var bindings = {exports: {}};
|
|
3305
|
-
|
|
3306
|
-
var fileUriToPath_1;
|
|
3307
|
-
var hasRequiredFileUriToPath;
|
|
3308
|
-
|
|
3309
|
-
function requireFileUriToPath () {
|
|
3310
|
-
if (hasRequiredFileUriToPath) return fileUriToPath_1;
|
|
3311
|
-
hasRequiredFileUriToPath = 1;
|
|
3312
|
-
/**
|
|
3313
|
-
* Module dependencies.
|
|
3314
|
-
*/
|
|
3315
|
-
|
|
3316
|
-
var sep = require$$0$1.sep || '/';
|
|
3317
|
-
|
|
3318
|
-
/**
|
|
3319
|
-
* Module exports.
|
|
3320
|
-
*/
|
|
3321
|
-
|
|
3322
|
-
fileUriToPath_1 = fileUriToPath;
|
|
3323
|
-
|
|
3324
|
-
/**
|
|
3325
|
-
* File URI to Path function.
|
|
3326
|
-
*
|
|
3327
|
-
* @param {String} uri
|
|
3328
|
-
* @return {String} path
|
|
3329
|
-
* @api public
|
|
3330
|
-
*/
|
|
3331
|
-
|
|
3332
|
-
function fileUriToPath (uri) {
|
|
3333
|
-
if ('string' != typeof uri ||
|
|
3334
|
-
uri.length <= 7 ||
|
|
3335
|
-
'file://' != uri.substring(0, 7)) {
|
|
3336
|
-
throw new TypeError('must pass in a file:// URI to convert to a file path');
|
|
3337
|
-
}
|
|
3338
|
-
|
|
3339
|
-
var rest = decodeURI(uri.substring(7));
|
|
3340
|
-
var firstSlash = rest.indexOf('/');
|
|
3341
|
-
var host = rest.substring(0, firstSlash);
|
|
3342
|
-
var path = rest.substring(firstSlash + 1);
|
|
3343
|
-
|
|
3344
|
-
// 2. Scheme Definition
|
|
3345
|
-
// As a special case, <host> can be the string "localhost" or the empty
|
|
3346
|
-
// string; this is interpreted as "the machine from which the URL is
|
|
3347
|
-
// being interpreted".
|
|
3348
|
-
if ('localhost' == host) host = '';
|
|
3349
|
-
|
|
3350
|
-
if (host) {
|
|
3351
|
-
host = sep + sep + host;
|
|
3352
|
-
}
|
|
3353
|
-
|
|
3354
|
-
// 3.2 Drives, drive letters, mount points, file system root
|
|
3355
|
-
// Drive letters are mapped into the top of a file URI in various ways,
|
|
3356
|
-
// depending on the implementation; some applications substitute
|
|
3357
|
-
// vertical bar ("|") for the colon after the drive letter, yielding
|
|
3358
|
-
// "file:///c|/tmp/test.txt". In some cases, the colon is left
|
|
3359
|
-
// unchanged, as in "file:///c:/tmp/test.txt". In other cases, the
|
|
3360
|
-
// colon is simply omitted, as in "file:///c/tmp/test.txt".
|
|
3361
|
-
path = path.replace(/^(.+)\|/, '$1:');
|
|
3362
|
-
|
|
3363
|
-
// for Windows, we need to invert the path separators from what a URI uses
|
|
3364
|
-
if (sep == '\\') {
|
|
3365
|
-
path = path.replace(/\//g, '\\');
|
|
3366
|
-
}
|
|
3367
|
-
|
|
3368
|
-
if (/^.+\:/.test(path)) ; else {
|
|
3369
|
-
// unix path…
|
|
3370
|
-
path = sep + path;
|
|
3371
|
-
}
|
|
3372
|
-
|
|
3373
|
-
return host + path;
|
|
3374
|
-
}
|
|
3375
|
-
return fileUriToPath_1;
|
|
3376
|
-
}
|
|
3377
|
-
|
|
3378
|
-
/**
|
|
3379
|
-
* Module dependencies.
|
|
3380
|
-
*/
|
|
3381
|
-
|
|
3382
|
-
var hasRequiredBindings;
|
|
3383
|
-
|
|
3384
|
-
function requireBindings () {
|
|
3385
|
-
if (hasRequiredBindings) return bindings.exports;
|
|
3386
|
-
hasRequiredBindings = 1;
|
|
3387
|
-
(function (module, exports) {
|
|
3388
|
-
var fs = require$$0$2,
|
|
3389
|
-
path = require$$0$1,
|
|
3390
|
-
fileURLToPath = requireFileUriToPath(),
|
|
3391
|
-
join = path.join,
|
|
3392
|
-
dirname = path.dirname,
|
|
3393
|
-
exists =
|
|
3394
|
-
(fs.accessSync &&
|
|
3395
|
-
function(path) {
|
|
3396
|
-
try {
|
|
3397
|
-
fs.accessSync(path);
|
|
3398
|
-
} catch (e) {
|
|
3399
|
-
return false;
|
|
3400
|
-
}
|
|
3401
|
-
return true;
|
|
3402
|
-
}) ||
|
|
3403
|
-
fs.existsSync ||
|
|
3404
|
-
path.existsSync,
|
|
3405
|
-
defaults = {
|
|
3406
|
-
arrow: process.env.NODE_BINDINGS_ARROW || ' → ',
|
|
3407
|
-
compiled: process.env.NODE_BINDINGS_COMPILED_DIR || 'compiled',
|
|
3408
|
-
platform: process.platform,
|
|
3409
|
-
arch: process.arch,
|
|
3410
|
-
nodePreGyp:
|
|
3411
|
-
'node-v' +
|
|
3412
|
-
process.versions.modules +
|
|
3413
|
-
'-' +
|
|
3414
|
-
process.platform +
|
|
3415
|
-
'-' +
|
|
3416
|
-
process.arch,
|
|
3417
|
-
version: process.versions.node,
|
|
3418
|
-
bindings: 'bindings.node',
|
|
3419
|
-
try: [
|
|
3420
|
-
// node-gyp's linked version in the "build" dir
|
|
3421
|
-
['module_root', 'build', 'bindings'],
|
|
3422
|
-
// node-waf and gyp_addon (a.k.a node-gyp)
|
|
3423
|
-
['module_root', 'build', 'Debug', 'bindings'],
|
|
3424
|
-
['module_root', 'build', 'Release', 'bindings'],
|
|
3425
|
-
// Debug files, for development (legacy behavior, remove for node v0.9)
|
|
3426
|
-
['module_root', 'out', 'Debug', 'bindings'],
|
|
3427
|
-
['module_root', 'Debug', 'bindings'],
|
|
3428
|
-
// Release files, but manually compiled (legacy behavior, remove for node v0.9)
|
|
3429
|
-
['module_root', 'out', 'Release', 'bindings'],
|
|
3430
|
-
['module_root', 'Release', 'bindings'],
|
|
3431
|
-
// Legacy from node-waf, node <= 0.4.x
|
|
3432
|
-
['module_root', 'build', 'default', 'bindings'],
|
|
3433
|
-
// Production "Release" buildtype binary (meh...)
|
|
3434
|
-
['module_root', 'compiled', 'version', 'platform', 'arch', 'bindings'],
|
|
3435
|
-
// node-qbs builds
|
|
3436
|
-
['module_root', 'addon-build', 'release', 'install-root', 'bindings'],
|
|
3437
|
-
['module_root', 'addon-build', 'debug', 'install-root', 'bindings'],
|
|
3438
|
-
['module_root', 'addon-build', 'default', 'install-root', 'bindings'],
|
|
3439
|
-
// node-pre-gyp path ./lib/binding/{node_abi}-{platform}-{arch}
|
|
3440
|
-
['module_root', 'lib', 'binding', 'nodePreGyp', 'bindings']
|
|
3441
|
-
]
|
|
3442
|
-
};
|
|
3443
|
-
|
|
3444
|
-
/**
|
|
3445
|
-
* The main `bindings()` function loads the compiled bindings for a given module.
|
|
3446
|
-
* It uses V8's Error API to determine the parent filename that this function is
|
|
3447
|
-
* being invoked from, which is then used to find the root directory.
|
|
3448
|
-
*/
|
|
3449
|
-
|
|
3450
|
-
function bindings(opts) {
|
|
3451
|
-
// Argument surgery
|
|
3452
|
-
if (typeof opts == 'string') {
|
|
3453
|
-
opts = { bindings: opts };
|
|
3454
|
-
} else if (!opts) {
|
|
3455
|
-
opts = {};
|
|
3456
|
-
}
|
|
3457
|
-
|
|
3458
|
-
// maps `defaults` onto `opts` object
|
|
3459
|
-
Object.keys(defaults).map(function(i) {
|
|
3460
|
-
if (!(i in opts)) opts[i] = defaults[i];
|
|
3461
|
-
});
|
|
3462
|
-
|
|
3463
|
-
// Get the module root
|
|
3464
|
-
if (!opts.module_root) {
|
|
3465
|
-
opts.module_root = exports.getRoot(exports.getFileName());
|
|
3466
|
-
}
|
|
3467
|
-
|
|
3468
|
-
// Ensure the given bindings name ends with .node
|
|
3469
|
-
if (path.extname(opts.bindings) != '.node') {
|
|
3470
|
-
opts.bindings += '.node';
|
|
3471
|
-
}
|
|
3472
|
-
|
|
3473
|
-
// https://github.com/webpack/webpack/issues/4175#issuecomment-342931035
|
|
3474
|
-
var requireFunc =
|
|
3475
|
-
typeof __webpack_require__ === 'function'
|
|
3476
|
-
? __non_webpack_require__
|
|
3477
|
-
: commonjsRequire;
|
|
3478
|
-
|
|
3479
|
-
var tries = [],
|
|
3480
|
-
i = 0,
|
|
3481
|
-
l = opts.try.length,
|
|
3482
|
-
n,
|
|
3483
|
-
b,
|
|
3484
|
-
err;
|
|
3485
|
-
|
|
3486
|
-
for (; i < l; i++) {
|
|
3487
|
-
n = join.apply(
|
|
3488
|
-
null,
|
|
3489
|
-
opts.try[i].map(function(p) {
|
|
3490
|
-
return opts[p] || p;
|
|
3491
|
-
})
|
|
3492
|
-
);
|
|
3493
|
-
tries.push(n);
|
|
3494
|
-
try {
|
|
3495
|
-
b = opts.path ? requireFunc.resolve(n) : requireFunc(n);
|
|
3496
|
-
if (!opts.path) {
|
|
3497
|
-
b.path = n;
|
|
3498
|
-
}
|
|
3499
|
-
return b;
|
|
3500
|
-
} catch (e) {
|
|
3501
|
-
if (e.code !== 'MODULE_NOT_FOUND' &&
|
|
3502
|
-
e.code !== 'QUALIFIED_PATH_RESOLUTION_FAILED' &&
|
|
3503
|
-
!/not find/i.test(e.message)) {
|
|
3504
|
-
throw e;
|
|
3505
|
-
}
|
|
3506
|
-
}
|
|
3507
|
-
}
|
|
3839
|
+
var browser = {};
|
|
3508
3840
|
|
|
3509
|
-
|
|
3510
|
-
'Could not locate the bindings file. Tried:\n' +
|
|
3511
|
-
tries
|
|
3512
|
-
.map(function(a) {
|
|
3513
|
-
return opts.arrow + a;
|
|
3514
|
-
})
|
|
3515
|
-
.join('\n')
|
|
3516
|
-
);
|
|
3517
|
-
err.tries = tries;
|
|
3518
|
-
throw err;
|
|
3519
|
-
}
|
|
3520
|
-
module.exports = exports = bindings;
|
|
3521
|
-
|
|
3522
|
-
/**
|
|
3523
|
-
* Gets the filename of the JavaScript file that invokes this function.
|
|
3524
|
-
* Used to help find the root directory of a module.
|
|
3525
|
-
* Optionally accepts an filename argument to skip when searching for the invoking filename
|
|
3526
|
-
*/
|
|
3527
|
-
|
|
3528
|
-
exports.getFileName = function getFileName(calling_file) {
|
|
3529
|
-
var origPST = Error.prepareStackTrace,
|
|
3530
|
-
origSTL = Error.stackTraceLimit,
|
|
3531
|
-
dummy = {},
|
|
3532
|
-
fileName;
|
|
3533
|
-
|
|
3534
|
-
Error.stackTraceLimit = 10;
|
|
3535
|
-
|
|
3536
|
-
Error.prepareStackTrace = function(e, st) {
|
|
3537
|
-
for (var i = 0, l = st.length; i < l; i++) {
|
|
3538
|
-
fileName = st[i].getFileName();
|
|
3539
|
-
if (fileName !== __filename) {
|
|
3540
|
-
if (calling_file) {
|
|
3541
|
-
if (fileName !== calling_file) {
|
|
3542
|
-
return;
|
|
3543
|
-
}
|
|
3544
|
-
} else {
|
|
3545
|
-
return;
|
|
3546
|
-
}
|
|
3547
|
-
}
|
|
3548
|
-
}
|
|
3549
|
-
};
|
|
3550
|
-
|
|
3551
|
-
// run the 'prepareStackTrace' function above
|
|
3552
|
-
Error.captureStackTrace(dummy);
|
|
3553
|
-
dummy.stack;
|
|
3554
|
-
|
|
3555
|
-
// cleanup
|
|
3556
|
-
Error.prepareStackTrace = origPST;
|
|
3557
|
-
Error.stackTraceLimit = origSTL;
|
|
3558
|
-
|
|
3559
|
-
// handle filename that starts with "file://"
|
|
3560
|
-
var fileSchema = 'file://';
|
|
3561
|
-
if (fileName.indexOf(fileSchema) === 0) {
|
|
3562
|
-
fileName = fileURLToPath(fileName);
|
|
3563
|
-
}
|
|
3564
|
-
|
|
3565
|
-
return fileName;
|
|
3566
|
-
};
|
|
3567
|
-
|
|
3568
|
-
/**
|
|
3569
|
-
* Gets the root directory of a module, given an arbitrary filename
|
|
3570
|
-
* somewhere in the module tree. The "root directory" is the directory
|
|
3571
|
-
* containing the `package.json` file.
|
|
3572
|
-
*
|
|
3573
|
-
* In: /home/nate/node-native-module/lib/index.js
|
|
3574
|
-
* Out: /home/nate/node-native-module
|
|
3575
|
-
*/
|
|
3576
|
-
|
|
3577
|
-
exports.getRoot = function getRoot(file) {
|
|
3578
|
-
var dir = dirname(file),
|
|
3579
|
-
prev;
|
|
3580
|
-
while (true) {
|
|
3581
|
-
if (dir === '.') {
|
|
3582
|
-
// Avoids an infinite loop in rare cases, like the REPL
|
|
3583
|
-
dir = process.cwd();
|
|
3584
|
-
}
|
|
3585
|
-
if (
|
|
3586
|
-
exists(join(dir, 'package.json')) ||
|
|
3587
|
-
exists(join(dir, 'node_modules'))
|
|
3588
|
-
) {
|
|
3589
|
-
// Found the 'package.json' file or 'node_modules' dir; we're done
|
|
3590
|
-
return dir;
|
|
3591
|
-
}
|
|
3592
|
-
if (prev === dir) {
|
|
3593
|
-
// Got to the top
|
|
3594
|
-
throw new Error(
|
|
3595
|
-
'Could not find module root given file: "' +
|
|
3596
|
-
file +
|
|
3597
|
-
'". Do you have a `package.json` file? '
|
|
3598
|
-
);
|
|
3599
|
-
}
|
|
3600
|
-
// Try the parent dir next
|
|
3601
|
-
prev = dir;
|
|
3602
|
-
dir = join(dir, '..');
|
|
3603
|
-
}
|
|
3604
|
-
};
|
|
3605
|
-
} (bindings, bindings.exports));
|
|
3606
|
-
return bindings.exports;
|
|
3607
|
-
}
|
|
3608
|
-
|
|
3609
|
-
Object.defineProperty(node, "__esModule", { value: true });
|
|
3610
|
-
let converter;
|
|
3611
|
-
{
|
|
3612
|
-
try {
|
|
3613
|
-
converter = requireBindings()('bigint_buffer');
|
|
3614
|
-
}
|
|
3615
|
-
catch (e) {
|
|
3616
|
-
console.warn('bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)');
|
|
3617
|
-
}
|
|
3618
|
-
}
|
|
3841
|
+
Object.defineProperty(browser, "__esModule", { value: true });
|
|
3619
3842
|
/**
|
|
3620
3843
|
* Convert a little-endian buffer into a BigInt.
|
|
3621
3844
|
* @param buf The little-endian buffer to convert
|
|
3622
3845
|
* @returns A BigInt with the little-endian representation of buf.
|
|
3623
3846
|
*/
|
|
3624
3847
|
function toBigIntLE(buf) {
|
|
3625
|
-
|
|
3848
|
+
{
|
|
3626
3849
|
const reversed = Buffer.from(buf);
|
|
3627
3850
|
reversed.reverse();
|
|
3628
3851
|
const hex = reversed.toString('hex');
|
|
@@ -3631,25 +3854,23 @@ function toBigIntLE(buf) {
|
|
|
3631
3854
|
}
|
|
3632
3855
|
return BigInt(`0x${hex}`);
|
|
3633
3856
|
}
|
|
3634
|
-
return converter.toBigInt(buf, false);
|
|
3635
3857
|
}
|
|
3636
|
-
var toBigIntLE_1 =
|
|
3858
|
+
var toBigIntLE_1 = browser.toBigIntLE = toBigIntLE;
|
|
3637
3859
|
/**
|
|
3638
3860
|
* Convert a big-endian buffer into a BigInt
|
|
3639
3861
|
* @param buf The big-endian buffer to convert.
|
|
3640
3862
|
* @returns A BigInt with the big-endian representation of buf.
|
|
3641
3863
|
*/
|
|
3642
3864
|
function toBigIntBE(buf) {
|
|
3643
|
-
|
|
3865
|
+
{
|
|
3644
3866
|
const hex = buf.toString('hex');
|
|
3645
3867
|
if (hex.length === 0) {
|
|
3646
3868
|
return BigInt(0);
|
|
3647
3869
|
}
|
|
3648
3870
|
return BigInt(`0x${hex}`);
|
|
3649
3871
|
}
|
|
3650
|
-
return converter.toBigInt(buf, true);
|
|
3651
3872
|
}
|
|
3652
|
-
|
|
3873
|
+
browser.toBigIntBE = toBigIntBE;
|
|
3653
3874
|
/**
|
|
3654
3875
|
* Convert a BigInt to a little-endian buffer.
|
|
3655
3876
|
* @param num The BigInt to convert.
|
|
@@ -3657,16 +3878,14 @@ node.toBigIntBE = toBigIntBE;
|
|
|
3657
3878
|
* @returns A little-endian buffer representation of num.
|
|
3658
3879
|
*/
|
|
3659
3880
|
function toBufferLE(num, width) {
|
|
3660
|
-
|
|
3881
|
+
{
|
|
3661
3882
|
const hex = num.toString(16);
|
|
3662
3883
|
const buffer = Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
|
|
3663
3884
|
buffer.reverse();
|
|
3664
3885
|
return buffer;
|
|
3665
3886
|
}
|
|
3666
|
-
// Allocation is done here, since it is slower using napi in C
|
|
3667
|
-
return converter.fromBigInt(num, Buffer.allocUnsafe(width), false);
|
|
3668
3887
|
}
|
|
3669
|
-
var toBufferLE_1 =
|
|
3888
|
+
var toBufferLE_1 = browser.toBufferLE = toBufferLE;
|
|
3670
3889
|
/**
|
|
3671
3890
|
* Convert a BigInt to a big-endian buffer.
|
|
3672
3891
|
* @param num The BigInt to convert.
|
|
@@ -3674,13 +3893,12 @@ var toBufferLE_1 = node.toBufferLE = toBufferLE;
|
|
|
3674
3893
|
* @returns A big-endian buffer representation of num.
|
|
3675
3894
|
*/
|
|
3676
3895
|
function toBufferBE(num, width) {
|
|
3677
|
-
|
|
3896
|
+
{
|
|
3678
3897
|
const hex = num.toString(16);
|
|
3679
3898
|
return Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');
|
|
3680
3899
|
}
|
|
3681
|
-
return converter.fromBigInt(num, Buffer.allocUnsafe(width), true);
|
|
3682
3900
|
}
|
|
3683
|
-
|
|
3901
|
+
browser.toBufferBE = toBufferBE;
|
|
3684
3902
|
|
|
3685
3903
|
const bigInt = (length) => (property) => {
|
|
3686
3904
|
const layout = blob(length, property);
|
|
@@ -3728,6 +3946,62 @@ const publicKey = (property) => {
|
|
|
3728
3946
|
return publicKeyLayout;
|
|
3729
3947
|
};
|
|
3730
3948
|
|
|
3949
|
+
/** Base class for errors */
|
|
3950
|
+
class TokenError extends Error {
|
|
3951
|
+
constructor(message) {
|
|
3952
|
+
super(message);
|
|
3953
|
+
}
|
|
3954
|
+
}
|
|
3955
|
+
/** Thrown if an account is not found at the expected address */
|
|
3956
|
+
class TokenAccountNotFoundError extends TokenError {
|
|
3957
|
+
constructor() {
|
|
3958
|
+
super(...arguments);
|
|
3959
|
+
this.name = 'TokenAccountNotFoundError';
|
|
3960
|
+
}
|
|
3961
|
+
}
|
|
3962
|
+
/** Thrown if a program state account is not a valid Account */
|
|
3963
|
+
class TokenInvalidAccountError extends TokenError {
|
|
3964
|
+
constructor() {
|
|
3965
|
+
super(...arguments);
|
|
3966
|
+
this.name = 'TokenInvalidAccountError';
|
|
3967
|
+
}
|
|
3968
|
+
}
|
|
3969
|
+
/** Thrown if a program state account is not owned by the expected token program */
|
|
3970
|
+
class TokenInvalidAccountOwnerError extends TokenError {
|
|
3971
|
+
constructor() {
|
|
3972
|
+
super(...arguments);
|
|
3973
|
+
this.name = 'TokenInvalidAccountOwnerError';
|
|
3974
|
+
}
|
|
3975
|
+
}
|
|
3976
|
+
/** Thrown if the byte length of an program state account doesn't match the expected size */
|
|
3977
|
+
class TokenInvalidAccountSizeError extends TokenError {
|
|
3978
|
+
constructor() {
|
|
3979
|
+
super(...arguments);
|
|
3980
|
+
this.name = 'TokenInvalidAccountSizeError';
|
|
3981
|
+
}
|
|
3982
|
+
}
|
|
3983
|
+
/** Thrown if the mint of a token account doesn't match the expected mint */
|
|
3984
|
+
class TokenInvalidMintError extends TokenError {
|
|
3985
|
+
constructor() {
|
|
3986
|
+
super(...arguments);
|
|
3987
|
+
this.name = 'TokenInvalidMintError';
|
|
3988
|
+
}
|
|
3989
|
+
}
|
|
3990
|
+
/** Thrown if the owner of a token account doesn't match the expected owner */
|
|
3991
|
+
class TokenInvalidOwnerError extends TokenError {
|
|
3992
|
+
constructor() {
|
|
3993
|
+
super(...arguments);
|
|
3994
|
+
this.name = 'TokenInvalidOwnerError';
|
|
3995
|
+
}
|
|
3996
|
+
}
|
|
3997
|
+
/** Thrown if the owner of a token account is a PDA (Program Derived Address) */
|
|
3998
|
+
class TokenOwnerOffCurveError extends TokenError {
|
|
3999
|
+
constructor() {
|
|
4000
|
+
super(...arguments);
|
|
4001
|
+
this.name = 'TokenOwnerOffCurveError';
|
|
4002
|
+
}
|
|
4003
|
+
}
|
|
4004
|
+
|
|
3731
4005
|
/** Instructions defined by the program */
|
|
3732
4006
|
var TokenInstruction;
|
|
3733
4007
|
(function (TokenInstruction) {
|
|
@@ -3767,6 +4041,10 @@ var TokenInstruction;
|
|
|
3767
4041
|
TokenInstruction[TokenInstruction["InterestBearingMintExtension"] = 33] = "InterestBearingMintExtension";
|
|
3768
4042
|
TokenInstruction[TokenInstruction["CpiGuardExtension"] = 34] = "CpiGuardExtension";
|
|
3769
4043
|
TokenInstruction[TokenInstruction["InitializePermanentDelegate"] = 35] = "InitializePermanentDelegate";
|
|
4044
|
+
TokenInstruction[TokenInstruction["TransferHookExtension"] = 36] = "TransferHookExtension";
|
|
4045
|
+
// ConfidentialTransferFeeExtension = 37,
|
|
4046
|
+
// WithdrawalExcessLamports = 38,
|
|
4047
|
+
TokenInstruction[TokenInstruction["MetadataPointerExtension"] = 39] = "MetadataPointerExtension";
|
|
3770
4048
|
})(TokenInstruction || (TokenInstruction = {}));
|
|
3771
4049
|
|
|
3772
4050
|
/** @internal */
|
|
@@ -3814,6 +4092,112 @@ function createApproveInstruction(account, delegate, owner, amount, multiSigners
|
|
|
3814
4092
|
return new web3_js.TransactionInstruction({ keys, programId, data });
|
|
3815
4093
|
}
|
|
3816
4094
|
|
|
4095
|
+
var AccountType;
|
|
4096
|
+
(function (AccountType) {
|
|
4097
|
+
AccountType[AccountType["Uninitialized"] = 0] = "Uninitialized";
|
|
4098
|
+
AccountType[AccountType["Mint"] = 1] = "Mint";
|
|
4099
|
+
AccountType[AccountType["Account"] = 2] = "Account";
|
|
4100
|
+
})(AccountType || (AccountType = {}));
|
|
4101
|
+
const ACCOUNT_TYPE_SIZE = 1;
|
|
4102
|
+
|
|
4103
|
+
/** Buffer layout for de/serializing a multisig */
|
|
4104
|
+
const MultisigLayout = struct([
|
|
4105
|
+
u8('m'),
|
|
4106
|
+
u8('n'),
|
|
4107
|
+
bool('isInitialized'),
|
|
4108
|
+
publicKey('signer1'),
|
|
4109
|
+
publicKey('signer2'),
|
|
4110
|
+
publicKey('signer3'),
|
|
4111
|
+
publicKey('signer4'),
|
|
4112
|
+
publicKey('signer5'),
|
|
4113
|
+
publicKey('signer6'),
|
|
4114
|
+
publicKey('signer7'),
|
|
4115
|
+
publicKey('signer8'),
|
|
4116
|
+
publicKey('signer9'),
|
|
4117
|
+
publicKey('signer10'),
|
|
4118
|
+
publicKey('signer11'),
|
|
4119
|
+
]);
|
|
4120
|
+
/** Byte length of a multisig */
|
|
4121
|
+
const MULTISIG_SIZE = MultisigLayout.span;
|
|
4122
|
+
|
|
4123
|
+
/** Token account state as stored by the program */
|
|
4124
|
+
var AccountState;
|
|
4125
|
+
(function (AccountState) {
|
|
4126
|
+
AccountState[AccountState["Uninitialized"] = 0] = "Uninitialized";
|
|
4127
|
+
AccountState[AccountState["Initialized"] = 1] = "Initialized";
|
|
4128
|
+
AccountState[AccountState["Frozen"] = 2] = "Frozen";
|
|
4129
|
+
})(AccountState || (AccountState = {}));
|
|
4130
|
+
/** Buffer layout for de/serializing a token account */
|
|
4131
|
+
const AccountLayout = struct([
|
|
4132
|
+
publicKey('mint'),
|
|
4133
|
+
publicKey('owner'),
|
|
4134
|
+
u64('amount'),
|
|
4135
|
+
u32('delegateOption'),
|
|
4136
|
+
publicKey('delegate'),
|
|
4137
|
+
u8('state'),
|
|
4138
|
+
u32('isNativeOption'),
|
|
4139
|
+
u64('isNative'),
|
|
4140
|
+
u64('delegatedAmount'),
|
|
4141
|
+
u32('closeAuthorityOption'),
|
|
4142
|
+
publicKey('closeAuthority'),
|
|
4143
|
+
]);
|
|
4144
|
+
/** Byte length of a token account */
|
|
4145
|
+
const ACCOUNT_SIZE = AccountLayout.span;
|
|
4146
|
+
/**
|
|
4147
|
+
* Retrieve information about a token account
|
|
4148
|
+
*
|
|
4149
|
+
* @param connection Connection to use
|
|
4150
|
+
* @param address Token account
|
|
4151
|
+
* @param commitment Desired level of commitment for querying the state
|
|
4152
|
+
* @param programId SPL Token program account
|
|
4153
|
+
*
|
|
4154
|
+
* @return Token account information
|
|
4155
|
+
*/
|
|
4156
|
+
async function getAccount(connection, address, commitment, programId = TOKEN_PROGRAM_ID) {
|
|
4157
|
+
const info = await connection.getAccountInfo(address, commitment);
|
|
4158
|
+
return unpackAccount(address, info, programId);
|
|
4159
|
+
}
|
|
4160
|
+
/**
|
|
4161
|
+
* Unpack a token account
|
|
4162
|
+
*
|
|
4163
|
+
* @param address Token account
|
|
4164
|
+
* @param info Token account data
|
|
4165
|
+
* @param programId SPL Token program account
|
|
4166
|
+
*
|
|
4167
|
+
* @return Unpacked token account
|
|
4168
|
+
*/
|
|
4169
|
+
function unpackAccount(address, info, programId = TOKEN_PROGRAM_ID) {
|
|
4170
|
+
if (!info)
|
|
4171
|
+
throw new TokenAccountNotFoundError();
|
|
4172
|
+
if (!info.owner.equals(programId))
|
|
4173
|
+
throw new TokenInvalidAccountOwnerError();
|
|
4174
|
+
if (info.data.length < ACCOUNT_SIZE)
|
|
4175
|
+
throw new TokenInvalidAccountSizeError();
|
|
4176
|
+
const rawAccount = AccountLayout.decode(info.data.slice(0, ACCOUNT_SIZE));
|
|
4177
|
+
let tlvData = Buffer.alloc(0);
|
|
4178
|
+
if (info.data.length > ACCOUNT_SIZE) {
|
|
4179
|
+
if (info.data.length === MULTISIG_SIZE)
|
|
4180
|
+
throw new TokenInvalidAccountSizeError();
|
|
4181
|
+
if (info.data[ACCOUNT_SIZE] != AccountType.Account)
|
|
4182
|
+
throw new TokenInvalidAccountError();
|
|
4183
|
+
tlvData = info.data.slice(ACCOUNT_SIZE + ACCOUNT_TYPE_SIZE);
|
|
4184
|
+
}
|
|
4185
|
+
return {
|
|
4186
|
+
address,
|
|
4187
|
+
mint: rawAccount.mint,
|
|
4188
|
+
owner: rawAccount.owner,
|
|
4189
|
+
amount: rawAccount.amount,
|
|
4190
|
+
delegate: rawAccount.delegateOption ? rawAccount.delegate : null,
|
|
4191
|
+
delegatedAmount: rawAccount.delegatedAmount,
|
|
4192
|
+
isInitialized: rawAccount.state !== AccountState.Uninitialized,
|
|
4193
|
+
isFrozen: rawAccount.state === AccountState.Frozen,
|
|
4194
|
+
isNative: !!rawAccount.isNativeOption,
|
|
4195
|
+
rentExemptReserve: rawAccount.isNativeOption ? rawAccount.isNative : null,
|
|
4196
|
+
closeAuthority: rawAccount.closeAuthorityOption ? rawAccount.closeAuthority : null,
|
|
4197
|
+
tlvData,
|
|
4198
|
+
};
|
|
4199
|
+
}
|
|
4200
|
+
|
|
3817
4201
|
/** Buffer layout for de/serializing a mint */
|
|
3818
4202
|
const MintLayout = struct([
|
|
3819
4203
|
u32('mintAuthorityOption'),
|
|
@@ -3826,6 +4210,54 @@ const MintLayout = struct([
|
|
|
3826
4210
|
]);
|
|
3827
4211
|
/** Byte length of a mint */
|
|
3828
4212
|
const MINT_SIZE = MintLayout.span;
|
|
4213
|
+
/**
|
|
4214
|
+
* Get the address of the associated token account for a given mint and owner
|
|
4215
|
+
*
|
|
4216
|
+
* @param mint Token mint account
|
|
4217
|
+
* @param owner Owner of the new account
|
|
4218
|
+
* @param allowOwnerOffCurve Allow the owner account to be a PDA (Program Derived Address)
|
|
4219
|
+
* @param programId SPL Token program account
|
|
4220
|
+
* @param associatedTokenProgramId SPL Associated Token program account
|
|
4221
|
+
*
|
|
4222
|
+
* @return Address of the associated token account
|
|
4223
|
+
*/
|
|
4224
|
+
function getAssociatedTokenAddressSync(mint, owner, allowOwnerOffCurve = false, programId = TOKEN_PROGRAM_ID, associatedTokenProgramId = ASSOCIATED_TOKEN_PROGRAM_ID) {
|
|
4225
|
+
if (!allowOwnerOffCurve && !web3_js.PublicKey.isOnCurve(owner.toBuffer()))
|
|
4226
|
+
throw new TokenOwnerOffCurveError();
|
|
4227
|
+
const [address] = web3_js.PublicKey.findProgramAddressSync([owner.toBuffer(), programId.toBuffer(), mint.toBuffer()], associatedTokenProgramId);
|
|
4228
|
+
return address;
|
|
4229
|
+
}
|
|
4230
|
+
|
|
4231
|
+
/**
|
|
4232
|
+
* Construct a CreateAssociatedTokenAccount instruction
|
|
4233
|
+
*
|
|
4234
|
+
* @param payer Payer of the initialization fees
|
|
4235
|
+
* @param associatedToken New associated token account
|
|
4236
|
+
* @param owner Owner of the new account
|
|
4237
|
+
* @param mint Token mint account
|
|
4238
|
+
* @param programId SPL Token program account
|
|
4239
|
+
* @param associatedTokenProgramId SPL Associated Token program account
|
|
4240
|
+
*
|
|
4241
|
+
* @return Instruction to add to a transaction
|
|
4242
|
+
*/
|
|
4243
|
+
function createAssociatedTokenAccountInstruction(payer, associatedToken, owner, mint, programId = TOKEN_PROGRAM_ID, associatedTokenProgramId = ASSOCIATED_TOKEN_PROGRAM_ID) {
|
|
4244
|
+
return buildAssociatedTokenAccountInstruction(payer, associatedToken, owner, mint, Buffer.alloc(0), programId, associatedTokenProgramId);
|
|
4245
|
+
}
|
|
4246
|
+
function buildAssociatedTokenAccountInstruction(payer, associatedToken, owner, mint, instructionData, programId = TOKEN_PROGRAM_ID, associatedTokenProgramId = ASSOCIATED_TOKEN_PROGRAM_ID) {
|
|
4247
|
+
const keys = [
|
|
4248
|
+
{ pubkey: payer, isSigner: true, isWritable: true },
|
|
4249
|
+
{ pubkey: associatedToken, isSigner: false, isWritable: true },
|
|
4250
|
+
{ pubkey: owner, isSigner: false, isWritable: false },
|
|
4251
|
+
{ pubkey: mint, isSigner: false, isWritable: false },
|
|
4252
|
+
{ pubkey: web3_js.SystemProgram.programId, isSigner: false, isWritable: false },
|
|
4253
|
+
{ pubkey: programId, isSigner: false, isWritable: false },
|
|
4254
|
+
];
|
|
4255
|
+
return new web3_js.TransactionInstruction({
|
|
4256
|
+
keys,
|
|
4257
|
+
programId: associatedTokenProgramId,
|
|
4258
|
+
data: instructionData,
|
|
4259
|
+
});
|
|
4260
|
+
}
|
|
3829
4261
|
|
|
3830
4262
|
/** TODO: docs */
|
|
3831
4263
|
const initializeMint2InstructionData = struct([
|
|
@@ -3859,10 +4291,93 @@ function createInitializeMint2Instruction(mint, decimals, mintAuthority, freezeA
|
|
|
3859
4291
|
return new web3_js.TransactionInstruction({ keys, programId, data });
|
|
3860
4292
|
}
|
|
3861
4293
|
|
|
3862
|
-
|
|
4294
|
+
/**
|
|
4295
|
+
* Retrieve the associated token account, or create it if it doesn't exist
|
|
4296
|
+
*
|
|
4297
|
+
* @param connection Connection to use
|
|
4298
|
+
* @param payer Payer of the transaction and initialization fees
|
|
4299
|
+
* @param mint Mint associated with the account to set or verify
|
|
4300
|
+
* @param owner Owner of the account to set or verify
|
|
4301
|
+
* @param allowOwnerOffCurve Allow the owner account to be a PDA (Program Derived Address)
|
|
4302
|
+
* @param commitment Desired level of commitment for querying the state
|
|
4303
|
+
* @param confirmOptions Options for confirming the transaction
|
|
4304
|
+
* @param programId SPL Token program account
|
|
4305
|
+
* @param associatedTokenProgramId SPL Associated Token program account
|
|
4306
|
+
*
|
|
4307
|
+
* @return Address of the new associated token account
|
|
4308
|
+
*/
|
|
4309
|
+
async function getOrCreateAssociatedTokenAccount(connection, payer, mint, owner, allowOwnerOffCurve = false, commitment, confirmOptions, programId = TOKEN_PROGRAM_ID, associatedTokenProgramId = ASSOCIATED_TOKEN_PROGRAM_ID) {
|
|
4310
|
+
const associatedToken = getAssociatedTokenAddressSync(mint, owner, allowOwnerOffCurve, programId, associatedTokenProgramId);
|
|
4311
|
+
// This is the optimal logic, considering TX fee, client-side computation, RPC roundtrips and guaranteed idempotent.
|
|
4312
|
+
// Sadly we can't do this atomically.
|
|
4313
|
+
let account;
|
|
4314
|
+
try {
|
|
4315
|
+
account = await getAccount(connection, associatedToken, commitment, programId);
|
|
4316
|
+
}
|
|
4317
|
+
catch (error) {
|
|
4318
|
+
// TokenAccountNotFoundError can be possible if the associated address has already received some lamports,
|
|
4319
|
+
// becoming a system account. Assuming program derived addressing is safe, this is the only case for the
|
|
4320
|
+
// TokenInvalidAccountOwnerError in this code path.
|
|
4321
|
+
if (error instanceof TokenAccountNotFoundError || error instanceof TokenInvalidAccountOwnerError) {
|
|
4322
|
+
// As this isn't atomic, it's possible others can create associated accounts meanwhile.
|
|
4323
|
+
try {
|
|
4324
|
+
const transaction = new web3_js.Transaction().add(createAssociatedTokenAccountInstruction(payer.publicKey, associatedToken, owner, mint, programId, associatedTokenProgramId));
|
|
4325
|
+
await web3_js.sendAndConfirmTransaction(connection, transaction, [payer], confirmOptions);
|
|
4326
|
+
}
|
|
4327
|
+
catch (error) {
|
|
4328
|
+
// Ignore all errors; for now there is no API-compatible way to selectively ignore the expected
|
|
4329
|
+
// instruction error if the associated account exists already.
|
|
4330
|
+
}
|
|
4331
|
+
// Now this should always succeed
|
|
4332
|
+
account = await getAccount(connection, associatedToken, commitment, programId);
|
|
4333
|
+
}
|
|
4334
|
+
else {
|
|
4335
|
+
throw error;
|
|
4336
|
+
}
|
|
4337
|
+
}
|
|
4338
|
+
if (!account.mint.equals(mint))
|
|
4339
|
+
throw new TokenInvalidMintError();
|
|
4340
|
+
if (!account.owner.equals(owner))
|
|
4341
|
+
throw new TokenInvalidOwnerError();
|
|
4342
|
+
return account;
|
|
4343
|
+
}
|
|
4344
|
+
|
|
4345
|
+
/** TODO: docs */
|
|
4346
|
+
const mintToInstructionData = struct([u8('instruction'), u64('amount')]);
|
|
4347
|
+
/**
|
|
4348
|
+
* Construct a MintTo instruction
|
|
4349
|
+
*
|
|
4350
|
+
* @param mint Public key of the mint
|
|
4351
|
+
* @param destination Address of the token account to mint to
|
|
4352
|
+
* @param authority The mint authority
|
|
4353
|
+
* @param amount Amount to mint
|
|
4354
|
+
* @param multiSigners Signing accounts if `authority` is a multisig
|
|
4355
|
+
* @param programId SPL Token program account
|
|
4356
|
+
*
|
|
4357
|
+
* @return Instruction to add to a transaction
|
|
4358
|
+
*/
|
|
4359
|
+
function createMintToInstruction(mint, destination, authority, amount, multiSigners = [], programId = TOKEN_PROGRAM_ID) {
|
|
4360
|
+
const keys = addSigners([
|
|
4361
|
+
{ pubkey: mint, isSigner: false, isWritable: true },
|
|
4362
|
+
{ pubkey: destination, isSigner: false, isWritable: true },
|
|
4363
|
+
], authority, multiSigners);
|
|
4364
|
+
const data = Buffer.alloc(mintToInstructionData.span);
|
|
4365
|
+
mintToInstructionData.encode({
|
|
4366
|
+
instruction: TokenInstruction.MintTo,
|
|
4367
|
+
amount: BigInt(amount),
|
|
4368
|
+
}, data);
|
|
4369
|
+
return new web3_js.TransactionInstruction({ keys, programId, data });
|
|
4370
|
+
}
|
|
4371
|
+
|
|
4372
|
+
/**
|
|
4373
|
+
* Sum up the token amounts of the compressed token accounts
|
|
4374
|
+
*/
|
|
3863
4375
|
const sumUpTokenAmount = (accounts) => {
|
|
3864
4376
|
return accounts.reduce((acc, account) => acc.add(account.parsed.amount), stateless_js.bn(0));
|
|
3865
4377
|
};
|
|
4378
|
+
/**
|
|
4379
|
+
* Validate that all the compressed token accounts are owned by the same owner.
|
|
4380
|
+
*/
|
|
3866
4381
|
const validateSameTokenOwner = (accounts) => {
|
|
3867
4382
|
const owner = accounts[0].parsed.owner;
|
|
3868
4383
|
accounts.forEach(acc => {
|
|
@@ -3871,12 +4386,23 @@ const validateSameTokenOwner = (accounts) => {
|
|
|
3871
4386
|
}
|
|
3872
4387
|
});
|
|
3873
4388
|
};
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
4389
|
+
/**
|
|
4390
|
+
* Parse compressed token accounts to get the mint, current owner and delegate.
|
|
4391
|
+
*/
|
|
4392
|
+
const parseTokenData = (compressedTokenAccounts) => {
|
|
4393
|
+
const mint = compressedTokenAccounts[0].parsed.mint;
|
|
4394
|
+
const currentOwner = compressedTokenAccounts[0].parsed.owner;
|
|
4395
|
+
const delegate = compressedTokenAccounts[0].parsed.delegate;
|
|
3878
4396
|
return { mint, currentOwner, delegate };
|
|
3879
4397
|
};
|
|
4398
|
+
/**
|
|
4399
|
+
* Create the output state for a transfer transaction.
|
|
4400
|
+
* @param inputCompressedTokenAccounts Input state
|
|
4401
|
+
* @param toAddress Recipient address
|
|
4402
|
+
* @param amount Amount of tokens to transfer
|
|
4403
|
+
* @returns Output token data for the transfer
|
|
4404
|
+
* instruction
|
|
4405
|
+
*/
|
|
3880
4406
|
function createTransferOutputState(inputCompressedTokenAccounts, toAddress, amount) {
|
|
3881
4407
|
amount = stateless_js.bn(amount);
|
|
3882
4408
|
const inputAmount = sumUpTokenAmount(inputCompressedTokenAccounts);
|
|
@@ -3909,6 +4435,13 @@ function createTransferOutputState(inputCompressedTokenAccounts, toAddress, amou
|
|
|
3909
4435
|
];
|
|
3910
4436
|
return outputCompressedAccounts;
|
|
3911
4437
|
}
|
|
4438
|
+
/**
|
|
4439
|
+
* Create the output state for a compress transaction.
|
|
4440
|
+
* @param inputCompressedTokenAccounts Input state
|
|
4441
|
+
* @param amount Amount of tokens to compress
|
|
4442
|
+
* @returns Output token data for the compress
|
|
4443
|
+
* instruction
|
|
4444
|
+
*/
|
|
3912
4445
|
function createDecompressOutputState(inputCompressedTokenAccounts, amount) {
|
|
3913
4446
|
amount = stateless_js.bn(amount);
|
|
3914
4447
|
const inputLamports = stateless_js.sumUpLamports(inputCompressedTokenAccounts.map(acc => acc.compressedAccount));
|
|
@@ -3935,6 +4468,7 @@ class CompressedTokenProgram {
|
|
|
3935
4468
|
* @internal
|
|
3936
4469
|
*/
|
|
3937
4470
|
constructor() { }
|
|
4471
|
+
/** @internal */
|
|
3938
4472
|
static get program() {
|
|
3939
4473
|
if (!this._program) {
|
|
3940
4474
|
this.initializeProgram();
|
|
@@ -3942,12 +4476,14 @@ class CompressedTokenProgram {
|
|
|
3942
4476
|
return this._program;
|
|
3943
4477
|
}
|
|
3944
4478
|
/**
|
|
4479
|
+
* @internal
|
|
3945
4480
|
* Initializes the program statically if not already initialized.
|
|
3946
4481
|
*/
|
|
3947
4482
|
static initializeProgram() {
|
|
3948
4483
|
if (!this._program) {
|
|
3949
|
-
/// We can use a mock connection because we're using the
|
|
3950
|
-
/// serde and building instructions, not for
|
|
4484
|
+
/// Note: We can use a mock connection because we're using the
|
|
4485
|
+
/// program only for serde and building instructions, not for
|
|
4486
|
+
/// interacting with the network.
|
|
3951
4487
|
const mockKeypair = web3_js.Keypair.generate();
|
|
3952
4488
|
const mockConnection = new web3_js.Connection('http://127.0.0.1:8899', 'confirmed');
|
|
3953
4489
|
const mockProvider = new anchor.AnchorProvider(mockConnection, stateless_js.useWallet(mockKeypair), stateless_js.confirmConfig);
|
|
@@ -3966,8 +4502,12 @@ class CompressedTokenProgram {
|
|
|
3966
4502
|
const [address, _] = web3_js.PublicKey.findProgramAddressSync([CPI_AUTHORITY_SEED], this.programId);
|
|
3967
4503
|
return address;
|
|
3968
4504
|
}
|
|
4505
|
+
/**
|
|
4506
|
+
* Construct createMint instruction for compressed tokens
|
|
4507
|
+
*/
|
|
3969
4508
|
static async createMint(params) {
|
|
3970
4509
|
const { mint, authority, feePayer, rentExemptBalance } = params;
|
|
4510
|
+
/// Create and initialize SPL Mint account
|
|
3971
4511
|
const createMintAccountInstruction = web3_js.SystemProgram.createAccount({
|
|
3972
4512
|
fromPubkey: feePayer,
|
|
3973
4513
|
lamports: rentExemptBalance,
|
|
@@ -3975,224 +4515,270 @@ class CompressedTokenProgram {
|
|
|
3975
4515
|
programId: TOKEN_PROGRAM_ID,
|
|
3976
4516
|
space: MINT_SIZE,
|
|
3977
4517
|
});
|
|
3978
|
-
const
|
|
3979
|
-
const
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
toPubkey: mintAuthorityPda,
|
|
3983
|
-
lamports: rentExemptBalance, // TODO: check that this is the right PDA size
|
|
4518
|
+
const initializeMintInstruction = createInitializeMint2Instruction(mint, params.decimals, authority, params.freezeAuthority, TOKEN_PROGRAM_ID);
|
|
4519
|
+
const ix = await this.registerMint({
|
|
4520
|
+
feePayer,
|
|
4521
|
+
mint,
|
|
3984
4522
|
});
|
|
4523
|
+
return [createMintAccountInstruction, initializeMintInstruction, ix];
|
|
4524
|
+
}
|
|
4525
|
+
/**
|
|
4526
|
+
* Enable compression for an existing SPL mint, creating an omnibus account.
|
|
4527
|
+
* For new mints, use `CompressedTokenProgram.createMint`.
|
|
4528
|
+
*/
|
|
4529
|
+
static async registerMint(params) {
|
|
4530
|
+
const { mint, feePayer } = params;
|
|
3985
4531
|
const tokenPoolPda = this.deriveTokenPoolPda(mint);
|
|
3986
4532
|
const ix = await this.program.methods
|
|
3987
4533
|
.createMint()
|
|
3988
4534
|
.accounts({
|
|
3989
4535
|
mint,
|
|
3990
4536
|
feePayer,
|
|
3991
|
-
authority,
|
|
3992
4537
|
tokenPoolPda,
|
|
3993
4538
|
systemProgram: web3_js.SystemProgram.programId,
|
|
3994
|
-
mintAuthorityPda,
|
|
3995
4539
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
3996
4540
|
cpiAuthorityPda: this.deriveCpiAuthorityPda,
|
|
3997
4541
|
})
|
|
3998
4542
|
.instruction();
|
|
3999
|
-
return
|
|
4000
|
-
createMintAccountInstruction,
|
|
4001
|
-
initializeMintInstruction,
|
|
4002
|
-
fundAuthorityPdaInstruction,
|
|
4003
|
-
ix,
|
|
4004
|
-
];
|
|
4543
|
+
return ix;
|
|
4005
4544
|
}
|
|
4545
|
+
/**
|
|
4546
|
+
* Construct mintTo instruction for compressed tokens
|
|
4547
|
+
*/
|
|
4006
4548
|
static async mintTo(params) {
|
|
4007
4549
|
const systemKeys = stateless_js.defaultStaticAccountsStruct();
|
|
4008
4550
|
const { mint, feePayer, authority, merkleTree, toPubkey, amount } = params;
|
|
4009
4551
|
const tokenPoolPda = this.deriveTokenPoolPda(mint);
|
|
4010
|
-
const mintAuthorityPda = this.deriveMintAuthorityPda(authority, mint);
|
|
4011
4552
|
const amounts = stateless_js.toArray(amount).map(amount => stateless_js.bn(amount));
|
|
4012
4553
|
const toPubkeys = stateless_js.toArray(toPubkey);
|
|
4013
|
-
const
|
|
4554
|
+
const instruction = await this.program.methods
|
|
4014
4555
|
.mintTo(toPubkeys, amounts)
|
|
4015
4556
|
.accounts({
|
|
4016
4557
|
feePayer,
|
|
4017
4558
|
authority,
|
|
4018
|
-
|
|
4559
|
+
cpiAuthorityPda: this.deriveCpiAuthorityPda,
|
|
4019
4560
|
mint,
|
|
4020
4561
|
tokenPoolPda,
|
|
4021
4562
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
4022
|
-
|
|
4563
|
+
lightSystemProgram: stateless_js.LightSystemProgram.programId,
|
|
4023
4564
|
registeredProgramPda: systemKeys.registeredProgramPda,
|
|
4024
4565
|
noopProgram: systemKeys.noopProgram,
|
|
4025
4566
|
accountCompressionAuthority: systemKeys.accountCompressionAuthority,
|
|
4026
4567
|
accountCompressionProgram: systemKeys.accountCompressionProgram,
|
|
4027
|
-
merkleTree,
|
|
4568
|
+
merkleTree: merkleTree !== null && merkleTree !== void 0 ? merkleTree : stateless_js.defaultTestStateTreeAccounts().merkleTree,
|
|
4028
4569
|
selfProgram: this.programId,
|
|
4029
4570
|
})
|
|
4030
4571
|
.instruction();
|
|
4031
|
-
return
|
|
4572
|
+
return instruction;
|
|
4573
|
+
}
|
|
4574
|
+
/// TODO: add compressBatch functionality for batch minting
|
|
4575
|
+
/**
|
|
4576
|
+
* Mint tokens from registed SPL mint account to a compressed account
|
|
4577
|
+
*/
|
|
4578
|
+
static async approveAndMintTo(params) {
|
|
4579
|
+
const { mint, feePayer, authorityTokenAccount, authority, merkleTree, toPubkey, } = params;
|
|
4580
|
+
const amount = BigInt(params.amount.toString());
|
|
4581
|
+
/// 1. Mint to existing ATA of mintAuthority.
|
|
4582
|
+
const splMintToInstruction = createMintToInstruction(mint, authorityTokenAccount, authority, amount);
|
|
4583
|
+
/// 2. Compress from mint authority ATA to recipient compressed account
|
|
4584
|
+
const [approveInstruction, compressInstruction] = await this.compress({
|
|
4585
|
+
payer: feePayer,
|
|
4586
|
+
owner: authority,
|
|
4587
|
+
source: authorityTokenAccount,
|
|
4588
|
+
toAddress: toPubkey,
|
|
4589
|
+
mint,
|
|
4590
|
+
amount: params.amount,
|
|
4591
|
+
outputStateTree: merkleTree,
|
|
4592
|
+
});
|
|
4593
|
+
return [splMintToInstruction, approveInstruction, compressInstruction];
|
|
4032
4594
|
}
|
|
4595
|
+
/**
|
|
4596
|
+
* Construct transfer instruction for compressed tokens
|
|
4597
|
+
*/
|
|
4033
4598
|
static async transfer(params) {
|
|
4034
4599
|
const { payer, inputCompressedTokenAccounts, recentInputStateRootIndices, recentValidityProof, amount, outputStateTrees, toAddress, } = params;
|
|
4035
|
-
const
|
|
4036
|
-
|
|
4037
|
-
const { inputTokenDataWithContext, outputStateMerkleTreeIndices, remainingAccountMetas, } = packCompressedTokenAccounts({
|
|
4600
|
+
const tokenTransferOutputs = createTransferOutputState(inputCompressedTokenAccounts, toAddress, amount);
|
|
4601
|
+
const { inputTokenDataWithContext, packedOutputTokenData, remainingAccountMetas, } = packCompressedTokenAccounts({
|
|
4038
4602
|
inputCompressedTokenAccounts,
|
|
4039
|
-
outputCompressedAccountsLength: outputCompressedAccounts.length,
|
|
4040
4603
|
outputStateTrees,
|
|
4604
|
+
rootIndices: recentInputStateRootIndices,
|
|
4605
|
+
tokenTransferOutputs,
|
|
4041
4606
|
});
|
|
4042
|
-
const { mint, currentOwner } =
|
|
4607
|
+
const { mint, currentOwner } = parseTokenData(inputCompressedTokenAccounts);
|
|
4043
4608
|
const data = {
|
|
4044
4609
|
proof: recentValidityProof,
|
|
4045
|
-
rootIndices: recentInputStateRootIndices,
|
|
4046
4610
|
mint,
|
|
4047
|
-
|
|
4611
|
+
delegatedTransfer: null, // TODO: implement
|
|
4048
4612
|
inputTokenDataWithContext,
|
|
4049
|
-
outputCompressedAccounts,
|
|
4050
|
-
|
|
4051
|
-
compressionAmount: null,
|
|
4613
|
+
outputCompressedAccounts: packedOutputTokenData,
|
|
4614
|
+
compressOrDecompressAmount: null,
|
|
4052
4615
|
isCompress: false,
|
|
4616
|
+
cpiContext: null,
|
|
4053
4617
|
};
|
|
4054
4618
|
const encodedData = this.program.coder.types.encode('CompressedTokenInstructionDataTransfer', data);
|
|
4055
4619
|
const { accountCompressionAuthority, noopProgram, registeredProgramPda, accountCompressionProgram, } = stateless_js.defaultStaticAccountsStruct();
|
|
4056
4620
|
const instruction = await this.program.methods
|
|
4057
|
-
.transfer(encodedData
|
|
4621
|
+
.transfer(encodedData)
|
|
4058
4622
|
.accounts({
|
|
4059
4623
|
feePayer: payer,
|
|
4060
4624
|
authority: currentOwner,
|
|
4061
4625
|
cpiAuthorityPda: this.deriveCpiAuthorityPda,
|
|
4062
|
-
|
|
4626
|
+
lightSystemProgram: stateless_js.LightSystemProgram.programId,
|
|
4063
4627
|
registeredProgramPda: registeredProgramPda,
|
|
4064
4628
|
noopProgram: noopProgram,
|
|
4065
4629
|
accountCompressionAuthority: accountCompressionAuthority,
|
|
4066
4630
|
accountCompressionProgram: accountCompressionProgram,
|
|
4067
4631
|
selfProgram: this.programId,
|
|
4068
4632
|
tokenPoolPda: null,
|
|
4069
|
-
|
|
4633
|
+
compressOrDecompressTokenAccount: null,
|
|
4070
4634
|
tokenProgram: null,
|
|
4071
4635
|
})
|
|
4072
4636
|
.remainingAccounts(remainingAccountMetas)
|
|
4073
4637
|
.instruction();
|
|
4074
|
-
return
|
|
4075
|
-
web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 1000000 }),
|
|
4076
|
-
instruction,
|
|
4077
|
-
];
|
|
4638
|
+
return instruction;
|
|
4078
4639
|
}
|
|
4640
|
+
/**
|
|
4641
|
+
* Construct approve and compress instructions
|
|
4642
|
+
* @returns [approveInstruction, compressInstruction]
|
|
4643
|
+
*/
|
|
4079
4644
|
static async compress(params) {
|
|
4080
4645
|
const { payer, owner, source, toAddress, mint, outputStateTree } = params;
|
|
4081
4646
|
const amount = stateless_js.bn(params.amount);
|
|
4082
|
-
const
|
|
4647
|
+
const tokenTransferOutputs = [
|
|
4083
4648
|
{
|
|
4084
4649
|
owner: toAddress,
|
|
4085
4650
|
amount,
|
|
4086
4651
|
lamports: stateless_js.bn(0),
|
|
4087
4652
|
},
|
|
4088
4653
|
];
|
|
4089
|
-
|
|
4090
|
-
const { inputTokenDataWithContext, outputStateMerkleTreeIndices, remainingAccountMetas, } = packCompressedTokenAccounts({
|
|
4654
|
+
const { inputTokenDataWithContext, packedOutputTokenData, remainingAccountMetas, } = packCompressedTokenAccounts({
|
|
4091
4655
|
inputCompressedTokenAccounts: [],
|
|
4092
|
-
|
|
4093
|
-
|
|
4656
|
+
outputStateTrees: outputStateTree,
|
|
4657
|
+
rootIndices: [],
|
|
4658
|
+
tokenTransferOutputs,
|
|
4094
4659
|
});
|
|
4095
4660
|
const data = {
|
|
4096
4661
|
proof: null,
|
|
4097
|
-
rootIndices: [],
|
|
4098
4662
|
mint,
|
|
4099
|
-
|
|
4663
|
+
delegatedTransfer: null, // TODO: implement
|
|
4100
4664
|
inputTokenDataWithContext,
|
|
4101
|
-
outputCompressedAccounts,
|
|
4102
|
-
|
|
4103
|
-
compressionAmount: amount,
|
|
4665
|
+
outputCompressedAccounts: packedOutputTokenData,
|
|
4666
|
+
compressOrDecompressAmount: amount,
|
|
4104
4667
|
isCompress: true,
|
|
4668
|
+
cpiContext: null,
|
|
4105
4669
|
};
|
|
4106
4670
|
const encodedData = this.program.coder.types.encode('CompressedTokenInstructionDataTransfer', data);
|
|
4107
4671
|
const { accountCompressionAuthority, noopProgram, registeredProgramPda, accountCompressionProgram, } = stateless_js.defaultStaticAccountsStruct();
|
|
4108
|
-
/// TODO: add support for multiSigners
|
|
4109
|
-
/// TODO: validate that we don't need approveChecked
|
|
4110
4672
|
const approveInstruction = createApproveInstruction(source, this.deriveCpiAuthorityPda, owner, BigInt(amount.toString()));
|
|
4111
4673
|
const instruction = await this.program.methods
|
|
4112
|
-
.transfer(encodedData
|
|
4674
|
+
.transfer(encodedData)
|
|
4113
4675
|
.accounts({
|
|
4114
4676
|
feePayer: payer,
|
|
4115
4677
|
authority: owner,
|
|
4116
4678
|
cpiAuthorityPda: this.deriveCpiAuthorityPda,
|
|
4117
|
-
|
|
4679
|
+
lightSystemProgram: stateless_js.LightSystemProgram.programId,
|
|
4118
4680
|
registeredProgramPda: registeredProgramPda,
|
|
4119
4681
|
noopProgram: noopProgram,
|
|
4120
4682
|
accountCompressionAuthority: accountCompressionAuthority,
|
|
4121
4683
|
accountCompressionProgram: accountCompressionProgram,
|
|
4122
4684
|
selfProgram: this.programId,
|
|
4123
4685
|
tokenPoolPda: this.deriveTokenPoolPda(mint),
|
|
4124
|
-
|
|
4686
|
+
compressOrDecompressTokenAccount: source, // token
|
|
4125
4687
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
4126
4688
|
})
|
|
4127
4689
|
.remainingAccounts(remainingAccountMetas)
|
|
4128
4690
|
.instruction();
|
|
4129
|
-
return [
|
|
4130
|
-
web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 1000000 }),
|
|
4131
|
-
approveInstruction,
|
|
4132
|
-
instruction,
|
|
4133
|
-
];
|
|
4691
|
+
return [approveInstruction, instruction];
|
|
4134
4692
|
}
|
|
4693
|
+
/**
|
|
4694
|
+
* Construct decompress instruction
|
|
4695
|
+
*/
|
|
4135
4696
|
static async decompress(params) {
|
|
4136
4697
|
const { payer, inputCompressedTokenAccounts, toAddress, outputStateTree, recentValidityProof, recentInputStateRootIndices, } = params;
|
|
4137
4698
|
const amount = stateless_js.bn(params.amount);
|
|
4138
4699
|
const tokenTransferOutputs = createDecompressOutputState(inputCompressedTokenAccounts, amount);
|
|
4139
4700
|
/// Pack
|
|
4140
|
-
const { inputTokenDataWithContext,
|
|
4701
|
+
const { inputTokenDataWithContext, packedOutputTokenData, remainingAccountMetas, } = packCompressedTokenAccounts({
|
|
4141
4702
|
inputCompressedTokenAccounts,
|
|
4142
|
-
|
|
4143
|
-
|
|
4703
|
+
outputStateTrees: outputStateTree,
|
|
4704
|
+
rootIndices: recentInputStateRootIndices,
|
|
4705
|
+
tokenTransferOutputs: tokenTransferOutputs,
|
|
4144
4706
|
});
|
|
4145
|
-
const { mint, currentOwner } =
|
|
4707
|
+
const { mint, currentOwner } = parseTokenData(inputCompressedTokenAccounts);
|
|
4146
4708
|
const data = {
|
|
4147
4709
|
proof: recentValidityProof,
|
|
4148
|
-
rootIndices: recentInputStateRootIndices,
|
|
4149
4710
|
mint,
|
|
4150
|
-
|
|
4711
|
+
delegatedTransfer: null, // TODO: implement
|
|
4151
4712
|
inputTokenDataWithContext,
|
|
4152
|
-
outputCompressedAccounts:
|
|
4153
|
-
|
|
4154
|
-
compressionAmount: amount,
|
|
4713
|
+
outputCompressedAccounts: packedOutputTokenData,
|
|
4714
|
+
compressOrDecompressAmount: amount,
|
|
4155
4715
|
isCompress: false,
|
|
4716
|
+
cpiContext: null,
|
|
4156
4717
|
};
|
|
4157
4718
|
const encodedData = this.program.coder.types.encode('CompressedTokenInstructionDataTransfer', data);
|
|
4158
4719
|
const { accountCompressionAuthority, noopProgram, registeredProgramPda, accountCompressionProgram, } = stateless_js.defaultStaticAccountsStruct();
|
|
4159
4720
|
const instruction = await this.program.methods
|
|
4160
|
-
.transfer(encodedData
|
|
4721
|
+
.transfer(encodedData)
|
|
4161
4722
|
.accounts({
|
|
4162
4723
|
feePayer: payer,
|
|
4163
4724
|
authority: currentOwner,
|
|
4164
4725
|
cpiAuthorityPda: this.deriveCpiAuthorityPda,
|
|
4165
|
-
|
|
4726
|
+
lightSystemProgram: stateless_js.LightSystemProgram.programId,
|
|
4166
4727
|
registeredProgramPda: registeredProgramPda,
|
|
4167
4728
|
noopProgram: noopProgram,
|
|
4168
4729
|
accountCompressionAuthority: accountCompressionAuthority,
|
|
4169
4730
|
accountCompressionProgram: accountCompressionProgram,
|
|
4170
4731
|
selfProgram: this.programId,
|
|
4171
4732
|
tokenPoolPda: this.deriveTokenPoolPda(mint),
|
|
4172
|
-
|
|
4733
|
+
compressOrDecompressTokenAccount: toAddress,
|
|
4173
4734
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
4174
4735
|
})
|
|
4175
4736
|
.remainingAccounts(remainingAccountMetas)
|
|
4176
4737
|
.instruction();
|
|
4177
|
-
return
|
|
4178
|
-
web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 1000000 }),
|
|
4179
|
-
instruction,
|
|
4180
|
-
];
|
|
4738
|
+
return instruction;
|
|
4181
4739
|
}
|
|
4182
4740
|
}
|
|
4183
|
-
_a = CompressedTokenProgram;
|
|
4184
4741
|
/**
|
|
4185
4742
|
* Public key that identifies the CompressedPda program
|
|
4186
4743
|
*/
|
|
4187
|
-
CompressedTokenProgram.programId = new web3_js.PublicKey(
|
|
4188
|
-
// TODO: can add check to ensure its consistent with the idl
|
|
4189
|
-
'9sixVEthz2kMSKfeApZXHwuboT6DZuT6crAYJTciUCqE');
|
|
4744
|
+
CompressedTokenProgram.programId = new web3_js.PublicKey('HXVfQ44ATEi9WBKLSCCwM54KokdkzqXci9xCQ7ST9SYN');
|
|
4190
4745
|
CompressedTokenProgram._program = null;
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4746
|
+
|
|
4747
|
+
/**
|
|
4748
|
+
* Mint compressed tokens to a solana address from an external mint authority
|
|
4749
|
+
*
|
|
4750
|
+
* @param rpc Rpc to use
|
|
4751
|
+
* @param payer Payer of the transaction fees
|
|
4752
|
+
* @param mint Mint for the account
|
|
4753
|
+
* @param destination Address of the account to mint to
|
|
4754
|
+
* @param authority Minting authority
|
|
4755
|
+
* @param amount Amount to mint
|
|
4756
|
+
* @param merkleTree State tree account that the compressed tokens should be
|
|
4757
|
+
* part of. Defaults to the default state tree account.
|
|
4758
|
+
* @param confirmOptions Options for confirming the transaction
|
|
4759
|
+
*
|
|
4760
|
+
* @return Signature of the confirmed transaction
|
|
4761
|
+
*/
|
|
4762
|
+
async function approveAndMintTo(rpc, payer, mint, destination, authority, amount, merkleTree, confirmOptions) {
|
|
4763
|
+
const authorityTokenAccount = await getOrCreateAssociatedTokenAccount(rpc, payer, mint, authority.publicKey);
|
|
4764
|
+
const ixs = await CompressedTokenProgram.approveAndMintTo({
|
|
4765
|
+
feePayer: payer.publicKey,
|
|
4766
|
+
mint,
|
|
4767
|
+
authority: authority.publicKey,
|
|
4768
|
+
authorityTokenAccount: authorityTokenAccount.address,
|
|
4769
|
+
amount,
|
|
4770
|
+
toPubkey: destination,
|
|
4771
|
+
merkleTree,
|
|
4772
|
+
});
|
|
4773
|
+
const { blockhash } = await rpc.getLatestBlockhash();
|
|
4774
|
+
const additionalSigners = stateless_js.dedupeSigner(payer, [authority]);
|
|
4775
|
+
const tx = stateless_js.buildAndSignTx([
|
|
4776
|
+
web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 1000000 }),
|
|
4777
|
+
...ixs,
|
|
4778
|
+
], payer, blockhash, additionalSigners);
|
|
4779
|
+
const txId = await stateless_js.sendAndConfirmTx(rpc, tx, confirmOptions);
|
|
4780
|
+
return txId;
|
|
4781
|
+
}
|
|
4196
4782
|
|
|
4197
4783
|
/**
|
|
4198
4784
|
* Compress SPL tokens
|
|
@@ -4212,9 +4798,9 @@ CompressedTokenProgram.deriveMintAuthorityPda = (authority, mint) => {
|
|
|
4212
4798
|
*
|
|
4213
4799
|
* @return Signature of the confirmed transaction
|
|
4214
4800
|
*/
|
|
4215
|
-
async function compress(rpc, payer, mint, amount, owner, sourceTokenAccount, toAddress, merkleTree
|
|
4801
|
+
async function compress(rpc, payer, mint, amount, owner, sourceTokenAccount, toAddress, merkleTree, confirmOptions) {
|
|
4216
4802
|
amount = stateless_js.bn(amount);
|
|
4217
|
-
const
|
|
4803
|
+
const [approveIx, compressIx] = await CompressedTokenProgram.compress({
|
|
4218
4804
|
payer: payer.publicKey,
|
|
4219
4805
|
owner: owner.publicKey,
|
|
4220
4806
|
source: sourceTokenAccount,
|
|
@@ -4225,7 +4811,13 @@ async function compress(rpc, payer, mint, amount, owner, sourceTokenAccount, toA
|
|
|
4225
4811
|
});
|
|
4226
4812
|
const blockhashCtx = await rpc.getLatestBlockhash();
|
|
4227
4813
|
const additionalSigners = stateless_js.dedupeSigner(payer, [owner]);
|
|
4228
|
-
const signedTx = stateless_js.buildAndSignTx(
|
|
4814
|
+
const signedTx = stateless_js.buildAndSignTx([
|
|
4815
|
+
web3_js.ComputeBudgetProgram.setComputeUnitLimit({
|
|
4816
|
+
units: 1000000,
|
|
4817
|
+
}),
|
|
4818
|
+
approveIx,
|
|
4819
|
+
compressIx,
|
|
4820
|
+
], payer, blockhashCtx.blockhash, additionalSigners);
|
|
4229
4821
|
const txId = await stateless_js.sendAndConfirmTx(rpc, signedTx, confirmOptions, blockhashCtx);
|
|
4230
4822
|
return txId;
|
|
4231
4823
|
}
|
|
@@ -4240,7 +4832,8 @@ async function compress(rpc, payer, mint, amount, owner, sourceTokenAccount, toA
|
|
|
4240
4832
|
* @param owner Owner of the compressed tokens
|
|
4241
4833
|
* @param toAddress Destination address of the recipient
|
|
4242
4834
|
* @param merkleTree State tree account that the compressed tokens should be
|
|
4243
|
-
* inserted into. Defaults to the default state tree
|
|
4835
|
+
* inserted into. Defaults to the default state tree
|
|
4836
|
+
* account.
|
|
4244
4837
|
* @param confirmOptions Options for confirming the transaction
|
|
4245
4838
|
*
|
|
4246
4839
|
*
|
|
@@ -4248,14 +4841,14 @@ async function compress(rpc, payer, mint, amount, owner, sourceTokenAccount, toA
|
|
|
4248
4841
|
*/
|
|
4249
4842
|
async function transfer(rpc, payer, mint, amount, owner, toAddress,
|
|
4250
4843
|
/// TODO: allow multiple
|
|
4251
|
-
merkleTree
|
|
4844
|
+
merkleTree, confirmOptions) {
|
|
4252
4845
|
amount = stateless_js.bn(amount);
|
|
4253
4846
|
const compressedTokenAccounts = await rpc.getCompressedTokenAccountsByOwner(owner.publicKey, {
|
|
4254
4847
|
mint,
|
|
4255
4848
|
});
|
|
4256
4849
|
const [inputAccounts] = selectMinCompressedTokenAccountsForTransfer(compressedTokenAccounts, amount);
|
|
4257
4850
|
const proof = await rpc.getValidityProof(inputAccounts.map(account => stateless_js.bn(account.compressedAccount.hash)));
|
|
4258
|
-
const
|
|
4851
|
+
const ix = await CompressedTokenProgram.transfer({
|
|
4259
4852
|
payer: payer.publicKey,
|
|
4260
4853
|
inputCompressedTokenAccounts: inputAccounts,
|
|
4261
4854
|
toAddress,
|
|
@@ -4266,7 +4859,7 @@ merkleTree = stateless_js.defaultTestStateTreeAccounts().merkleTree, confirmOpti
|
|
|
4266
4859
|
});
|
|
4267
4860
|
const { blockhash } = await rpc.getLatestBlockhash();
|
|
4268
4861
|
const additionalSigners = stateless_js.dedupeSigner(payer, [owner]);
|
|
4269
|
-
const signedTx = stateless_js.buildAndSignTx(
|
|
4862
|
+
const signedTx = stateless_js.buildAndSignTx([web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 1000000 }), ix], payer, blockhash, additionalSigners);
|
|
4270
4863
|
const txId = await stateless_js.sendAndConfirmTx(rpc, signedTx, confirmOptions);
|
|
4271
4864
|
return txId;
|
|
4272
4865
|
}
|
|
@@ -4319,7 +4912,7 @@ function selectMinCompressedTokenAccountsForTransfer(accounts, transferAmount) {
|
|
|
4319
4912
|
*/
|
|
4320
4913
|
async function decompress(rpc, payer, mint, amount, owner, toAddress,
|
|
4321
4914
|
/// TODO: allow multiple
|
|
4322
|
-
merkleTree
|
|
4915
|
+
merkleTree, confirmOptions) {
|
|
4323
4916
|
amount = stateless_js.bn(amount);
|
|
4324
4917
|
const compressedTokenAccounts = await rpc.getCompressedTokenAccountsByOwner(owner.publicKey, {
|
|
4325
4918
|
mint,
|
|
@@ -4327,7 +4920,7 @@ merkleTree = stateless_js.defaultTestStateTreeAccounts().merkleTree, confirmOpti
|
|
|
4327
4920
|
/// TODO: consider using a different selection algorithm
|
|
4328
4921
|
const [inputAccounts] = selectMinCompressedTokenAccountsForTransfer(compressedTokenAccounts, amount);
|
|
4329
4922
|
const proof = await rpc.getValidityProof(inputAccounts.map(account => stateless_js.bn(account.compressedAccount.hash)));
|
|
4330
|
-
const
|
|
4923
|
+
const ix = await CompressedTokenProgram.decompress({
|
|
4331
4924
|
payer: payer.publicKey,
|
|
4332
4925
|
inputCompressedTokenAccounts: inputAccounts,
|
|
4333
4926
|
toAddress, // TODO: add explicit check that it is a token account
|
|
@@ -4338,7 +4931,7 @@ merkleTree = stateless_js.defaultTestStateTreeAccounts().merkleTree, confirmOpti
|
|
|
4338
4931
|
});
|
|
4339
4932
|
const { blockhash } = await rpc.getLatestBlockhash();
|
|
4340
4933
|
const additionalSigners = stateless_js.dedupeSigner(payer, [owner]);
|
|
4341
|
-
const signedTx = stateless_js.buildAndSignTx(
|
|
4934
|
+
const signedTx = stateless_js.buildAndSignTx([web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 1000000 }), ix], payer, blockhash, additionalSigners);
|
|
4342
4935
|
const txId = await stateless_js.sendAndConfirmTx(rpc, signedTx, confirmOptions);
|
|
4343
4936
|
return txId;
|
|
4344
4937
|
}
|
|
@@ -4348,7 +4941,7 @@ merkleTree = stateless_js.defaultTestStateTreeAccounts().merkleTree, confirmOpti
|
|
|
4348
4941
|
*
|
|
4349
4942
|
* @param rpc RPC to use
|
|
4350
4943
|
* @param payer Payer of the transaction and initialization fees
|
|
4351
|
-
* @param mintAuthority Account or multisig that will control minting
|
|
4944
|
+
* @param mintAuthority Account or multisig that will control minting
|
|
4352
4945
|
* @param decimals Location of the decimal place
|
|
4353
4946
|
* @param keypair Optional keypair, defaulting to a new random one
|
|
4354
4947
|
* @param confirmOptions Options for confirming the transaction
|
|
@@ -4361,12 +4954,12 @@ async function createMint(rpc, payer, mintAuthority, decimals, keypair = web3_js
|
|
|
4361
4954
|
feePayer: payer.publicKey,
|
|
4362
4955
|
mint: keypair.publicKey,
|
|
4363
4956
|
decimals,
|
|
4364
|
-
authority: mintAuthority
|
|
4957
|
+
authority: mintAuthority,
|
|
4365
4958
|
freezeAuthority: null, // TODO: add feature
|
|
4366
4959
|
rentExemptBalance,
|
|
4367
4960
|
});
|
|
4368
4961
|
const { blockhash } = await rpc.getLatestBlockhash();
|
|
4369
|
-
const additionalSigners = stateless_js.dedupeSigner(payer, [
|
|
4962
|
+
const additionalSigners = stateless_js.dedupeSigner(payer, [keypair]);
|
|
4370
4963
|
const tx = stateless_js.buildAndSignTx(ixs, payer, blockhash, additionalSigners);
|
|
4371
4964
|
const txId = await stateless_js.sendAndConfirmTx(rpc, tx, confirmOptions);
|
|
4372
4965
|
return { mint: keypair.publicKey, transactionSignature: txId };
|
|
@@ -4387,8 +4980,7 @@ async function createMint(rpc, payer, mintAuthority, decimals, keypair = web3_js
|
|
|
4387
4980
|
*
|
|
4388
4981
|
* @return Signature of the confirmed transaction
|
|
4389
4982
|
*/
|
|
4390
|
-
async function mintTo(rpc, payer, mint, destination, authority, amount, merkleTree
|
|
4391
|
-
confirmOptions) {
|
|
4983
|
+
async function mintTo(rpc, payer, mint, destination, authority, amount, merkleTree, confirmOptions) {
|
|
4392
4984
|
const additionalSigners = stateless_js.dedupeSigner(payer, [authority]);
|
|
4393
4985
|
const ix = await CompressedTokenProgram.mintTo({
|
|
4394
4986
|
feePayer: payer.publicKey,
|
|
@@ -4404,12 +4996,34 @@ confirmOptions) {
|
|
|
4404
4996
|
return txId;
|
|
4405
4997
|
}
|
|
4406
4998
|
|
|
4999
|
+
/**
|
|
5000
|
+
* Register an existing mint with the CompressedToken program
|
|
5001
|
+
*
|
|
5002
|
+
* @param rpc RPC to use
|
|
5003
|
+
* @param payer Payer of the transaction and initialization fees
|
|
5004
|
+
* @param mintAuthority Account or multisig that will control minting. Is signer.
|
|
5005
|
+
* @param mintAddress Address of the existing mint
|
|
5006
|
+
* @param confirmOptions Options for confirming the transaction
|
|
5007
|
+
*
|
|
5008
|
+
* @return transaction signature
|
|
5009
|
+
*/
|
|
5010
|
+
async function registerMint(rpc, payer, mintAddress, confirmOptions) {
|
|
5011
|
+
const ix = await CompressedTokenProgram.registerMint({
|
|
5012
|
+
feePayer: payer.publicKey,
|
|
5013
|
+
mint: mintAddress,
|
|
5014
|
+
});
|
|
5015
|
+
const { blockhash } = await rpc.getLatestBlockhash();
|
|
5016
|
+
const tx = stateless_js.buildAndSignTx([ix], payer, blockhash);
|
|
5017
|
+
const txId = await stateless_js.sendAndConfirmTx(rpc, tx, confirmOptions);
|
|
5018
|
+
return txId;
|
|
5019
|
+
}
|
|
5020
|
+
|
|
4407
5021
|
exports.CPI_AUTHORITY_SEED = CPI_AUTHORITY_SEED;
|
|
4408
5022
|
exports.CompressedTokenProgram = CompressedTokenProgram;
|
|
4409
5023
|
exports.IDL = IDL;
|
|
4410
|
-
exports.MINT_AUTHORITY_SEED = MINT_AUTHORITY_SEED;
|
|
4411
5024
|
exports.POOL_SEED = POOL_SEED;
|
|
4412
5025
|
exports.SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE = SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE;
|
|
5026
|
+
exports.approveAndMintTo = approveAndMintTo;
|
|
4413
5027
|
exports.compress = compress;
|
|
4414
5028
|
exports.createDecompressOutputState = createDecompressOutputState;
|
|
4415
5029
|
exports.createMint = createMint;
|
|
@@ -4417,7 +5031,8 @@ exports.createTransferOutputState = createTransferOutputState;
|
|
|
4417
5031
|
exports.decompress = decompress;
|
|
4418
5032
|
exports.mintTo = mintTo;
|
|
4419
5033
|
exports.packCompressedTokenAccounts = packCompressedTokenAccounts;
|
|
4420
|
-
exports.
|
|
5034
|
+
exports.parseTokenData = parseTokenData;
|
|
5035
|
+
exports.registerMint = registerMint;
|
|
4421
5036
|
exports.selectMinCompressedTokenAccountsForTransfer = selectMinCompressedTokenAccountsForTransfer;
|
|
4422
5037
|
exports.sumUpTokenAmount = sumUpTokenAmount;
|
|
4423
5038
|
exports.transfer = transfer;
|