mpl-nft-packs 0.1.0

NFT Packs: mystery packs NFTs that are not revealed until after opening the pack.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
//! Instruction types
#![allow(missing_docs)]

use crate::{
    find_pack_card_program_address, find_pack_config_program_address,
    find_pack_voucher_program_address, find_program_authority,
    find_proving_process_program_address, state::PackDistributionType,
};
use borsh::{BorshDeserialize, BorshSerialize};
use shank::ShankInstruction;
use solana_program::{
    instruction::{AccountMeta, Instruction},
    pubkey::Pubkey,
    system_program, sysvar,
};

#[repr(C)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
pub struct AddCardToPackArgs {
    /// How many editions of this card will exists in pack
    pub max_supply: u32,
    /// Probability value, required only if PackSet distribution type == Fixed
    pub weight: u16,
    /// Index
    pub index: u32,
}

/// Initialize a PackSet arguments
#[repr(C)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
pub struct InitPackSetArgs {
    /// Name
    pub name: [u8; 32],
    /// Description
    pub description: String,
    /// Pack set preview image
    pub uri: String,
    /// If true authority can make changes at deactivated phase
    pub mutable: bool,
    /// Distribution type
    pub distribution_type: PackDistributionType,
    /// Allowed amount to redeem
    pub allowed_amount_to_redeem: u32,
    /// Redeem start date, if not filled set current timestamp
    pub redeem_start_date: Option<u64>,
    /// Redeem end date
    pub redeem_end_date: Option<u64>,
}

/// Edit a PackSet arguments
#[repr(C)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
pub struct EditPackSetArgs {
    /// Name
    pub name: Option<[u8; 32]>,
    /// Description
    pub description: Option<String>,
    /// URI
    pub uri: Option<String>,
    /// If true authority can make changes at deactivated phase
    pub mutable: Option<bool>,
}

/// Claim card from pack
#[repr(C)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
pub struct ClaimPackArgs {
    /// Card index
    pub index: u32,
}

/// Request card to redeem arguments
#[repr(C)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
pub struct RequestCardToRedeemArgs {
    /// Voucher index
    pub index: u32,
}

/// Instruction definition
#[derive(BorshSerialize, BorshDeserialize, Clone, ShankInstruction)]
pub enum NFTPacksInstruction {
    /// InitPack
    ///
    /// Initialize created account.
    ///
    /// Parameters:
    /// - name [u8; 32]
    /// - description String
    /// - URI String
    /// - mutable    bool
    /// - distribution_type    DistributionType
    /// - allowed_amount_to_redeem    u32
    /// - redeem_start_date    Option<u64>
    /// - redeem_end_date    Option<u64>
    #[account(0, writable, name = "pack_set")]
    #[account(1, signer, name = "authority")]
    #[account(2, name = "store")]
    #[account(3, name = "rent", desc = "Rent account")]
    #[account(4, name = "clock", desc = "Clock account")]
    #[account(5, optional, name = "whitelisted_creator")]
    InitPack(InitPackSetArgs),

    /// AddCardToPack
    ///
    /// Creates new account with PackCard structure and program token account which will hold MasterEdition token.
    /// Also admin points how many items of this specific MasterEdition will be in the pack. Check MasterEdition for V2.
    ///
    /// Parameters:
    /// - max_supply    Option<u32>
    /// - probability_type   enum[fixed number, probability based]
    /// - probability    u64

    #[account(0, writable, name = "pack_set")]
    #[account(1, writable, name = "pack_config", desc = "PDA, ['config', pack]")]
    #[account(2, writable, name = "pack_card", desc = "PDA, ['card', pack, index]")]
    #[account(3, signer, name = "authority")]
    #[account(4, name = "master_edition")]
    #[account(5, name = "master_metadata")]
    #[account(6, name = "mint")]
    #[account(7, writable, name = "source")]
    #[account(
        8,
        writable,
        name = "token_account",
        desc = "program account to hold MasterEdition token"
    )]
    #[account(9, name = "program_authority")]
    #[account(10, name = "store")]
    #[account(11, name = "rent", desc = "Rent")]
    #[account(12, name = "system_program", desc = "System Program")]
    #[account(13, name = "token_program", desc = "SPL Token program")]
    AddCardToPack(AddCardToPackArgs),

    /// AddVoucherToPack
    ///
    /// Creates new account with PackVoucher structure, saves there data about NFTs which user has to provide to open the pack.
    /// Check MasterEdition for V2.
    ///
    #[account(0, writable, name = "pack_set")]
    #[account(
        1,
        writable,
        name = "pack_voucher",
        desc = "PDA, ['voucher', pack, index]"
    )]
    #[account(2, signer, writable, name = "authority")]
    #[account(3, signer, name = "voucher_owner")]
    #[account(4, name = "master_edition")]
    #[account(5, name = "master_metadata")]
    #[account(6, name = "mint")]
    #[account(7, writable, name = "source")]
    #[account(8, name = "store")]
    #[account(9, name = "rent", desc = "Rent")]
    #[account(10, name = "system_program", desc = "System Program")]
    #[account(11, name = "token_program", desc = "SPL Token program")]
    AddVoucherToPack,

    /// Activate
    ///
    /// Pack authority call this instruction to activate pack, means close for changing.
    ///
    #[account(0, writable, name = "pack_set")]
    #[account(1, signer, name = "authority")]
    Activate,

    /// Deactivate
    ///
    /// Forbid users prove vouchers ownership and claiming.
    ///
    #[account(0, writable, name = "pack_set")]
    #[account(1, signer, name = "authority")]
    Deactivate,

    /// Close the pack
    ///
    /// Set pack state to "ended", irreversible operation
    ///
    #[account(0, writable, name = "pack_set")]
    #[account(1, signer, name = "authority")]
    #[account(2, name = "clock", desc = "Solana Clock")]
    ClosePack,

    /// ClaimPack
    ///
    /// Call this instruction with ProvingProcess and PackCard accounts and program will transfer
    /// MasterEdition to user account or return empty response depends successfully or not user open pack with specific MasterEdition.
    ///
    /// Parameters:
    /// - index             u32
    #[account(0, name = "pack_set")]
    #[account(
        1,
        writable,
        name = "proving_process",
        desc = "PDA, ['proving', pack, user_wallet]"
    )]
    #[account(2, signer, name = "user_wallet")]
    #[account(3, writable, name = "pack_card", desc = "PDA, ['card', pack, index]")]
    #[account(
        4,
        writable,
        name = "user_token",
        desc = "User token account to hold new minted edition"
    )]
    #[account(5, name = "new_metadata")]
    #[account(6, name = "new_edition")]
    #[account(7, name = "master_edition")]
    #[account(8, name = "new_mint")]
    #[account(9, signer, name = "new_mint_authority")]
    #[account(10, name = "metadata")]
    #[account(11, name = "metadata_mint")]
    #[account(12, name = "edition_marker")]
    #[account(13, name = "rent", desc = "Rent")]
    #[account(
        14,
        name = "token_metadata_program",
        desc = "Metaplex Token Metadata Program"
    )]
    #[account(15, name = "token_program", desc = "SPL Token program")]
    #[account(16, name = "system_program", desc = "System Program")]
    ClaimPack(ClaimPackArgs),

    /// TransferPackAuthority
    ///
    /// Change pack authority.
    ///
    #[account(0, writable, name = "pack_set")]
    #[account(1, signer, name = "current_authority")]
    #[account(2, name = "new_authority")]
    TransferPackAuthority,

    /// DeletePack
    ///
    /// Transfer all the SOL from pack set account to refunder account and thus remove it.
    ///
    #[account(0, writable, name = "pack_set")]
    #[account(1, signer, name = "authority")]
    #[account(2, writable, name = "refunder")]
    DeletePack,

    /// DeletePackCard
    ///
    /// Transfer all the SOL from pack card account to refunder account and thus remove it.
    /// Also transfer master token to new owner.
    ///
    #[account(0, writable, name = "pack_set")]
    #[account(1, writable, name = "pack_card")]
    #[account(2, signer, name = "authority")]
    #[account(3, writable, name = "refunder")]
    #[account(4, writable, name = "new_master_edition_owner")]
    #[account(5, writable, name = "token_account")]
    #[account(6, name = "program_authority")]
    #[account(7, name = "rent", desc = "Rent")]
    #[account(8, name = "token_program", desc = "SPL Token program")]
    DeletePackCard,

    /// DeletePackVoucher
    ///
    /// Transfer all the SOL from pack voucher account to refunder account and thus remove it.
    ///
    #[account(0, writable, name = "pack_set")]
    #[account(1, writable, name = "pack_voucher")]
    #[account(2, signer, name = "authority")]
    #[account(3, writable, name = "refunder")]
    DeletePackVoucher,

    /// EditPack
    ///
    /// Edit pack data.
    ///
    /// Parameters:
    /// - name Option<[u8; 32]>
    /// - description Option<String>
    /// - URI Option<String>
    /// - mutable Option<bool> (only can be changed from true to false)
    #[account(0, writable, name = "pack_set")]
    #[account(1, signer, name = "authority")]
    EditPack(EditPackSetArgs),

    /// RequestCardForRedeem
    ///
    /// Count card index which user can redeem next
    ///
    /// Parameters:
    /// - index    u32
    #[account(0, name = "pack_set")]
    #[account(1, writable, name = "pack_config", desc = "PDA, ['config', pack]")]
    #[account(2, name = "store")]
    #[account(3, name = "edition")]
    #[account(4, name = "edition_mint")]
    #[account(5, name = "pack_voucher")]
    #[account(
        6,
        writable,
        name = "proving_process",
        desc = "PDA, ['proving', pack, user_wallet]"
    )]
    #[account(7, signer, name = "user_wallet")]
    #[account(8, name = "recent_slothashes", desc = "Solana Slot Hashes")]
    #[account(9, name = "clock", desc = "Solana Clock")]
    #[account(10, name = "rent", desc = "Rent")]
    #[account(11, name = "system_program", desc = "System Program")]
    #[account(12, optional, name = "user_token")]
    RequestCardForRedeem(RequestCardToRedeemArgs),

    /// CleanUp
    ///
    /// Sorts weights of all the cards and removes exhausted
    ///
    #[account(0, name = "pack_set")]
    #[account(1, writable, name = "pack_config", desc = "PDA, ['config', pack]")]
    CleanUp,

    /// Delete PackConfig account
    ///
    /// Transfer all the SOL from pack card account to refunder account and thus remove it.
    ///
    #[account(0, name = "pack_set")]
    #[account(1, writable, name = "pack_config", desc = "PDA, ['config', pack]")]
    #[account(2, writable, name = "refunder")]
    #[account(3, signer, name = "authority")]
    DeletePackConfig,
}

/// Create `InitPack` instruction
pub fn init_pack(
    program_id: &Pubkey,
    pack_set: &Pubkey,
    authority: &Pubkey,
    store: &Pubkey,
    whitelisted_creator: &Pubkey,
    args: InitPackSetArgs,
) -> Instruction {
    let accounts = vec![
        AccountMeta::new(*pack_set, false),
        AccountMeta::new_readonly(*authority, true),
        AccountMeta::new_readonly(*store, false),
        AccountMeta::new_readonly(sysvar::rent::id(), false),
        AccountMeta::new_readonly(sysvar::clock::id(), false),
        AccountMeta::new_readonly(*whitelisted_creator, false),
    ];

    Instruction::new_with_borsh(*program_id, &NFTPacksInstruction::InitPack(args), accounts)
}

/// Creates 'AddCardToPack' instruction.
#[allow(clippy::too_many_arguments)]
pub fn add_card_to_pack(
    program_id: &Pubkey,
    pack_set: &Pubkey,
    authority: &Pubkey,
    master_edition: &Pubkey,
    master_metadata: &Pubkey,
    mint: &Pubkey,
    source: &Pubkey,
    token_account: &Pubkey,
    store: &Pubkey,
    args: AddCardToPackArgs,
) -> Instruction {
    let (program_authority, _) = find_program_authority(program_id);
    let (pack_card, _) = find_pack_card_program_address(program_id, pack_set, args.index);
    let (pack_config, _) = find_pack_config_program_address(program_id, pack_set);

    let accounts = vec![
        AccountMeta::new(*pack_set, false),
        AccountMeta::new(pack_config, false),
        AccountMeta::new(pack_card, false),
        AccountMeta::new(*authority, true),
        AccountMeta::new_readonly(*master_edition, false),
        AccountMeta::new_readonly(*master_metadata, false),
        AccountMeta::new_readonly(*mint, false),
        AccountMeta::new(*source, false),
        AccountMeta::new(*token_account, false),
        AccountMeta::new(program_authority, false),
        AccountMeta::new_readonly(*store, false),
        AccountMeta::new_readonly(sysvar::rent::id(), false),
        AccountMeta::new_readonly(system_program::id(), false),
        AccountMeta::new_readonly(spl_token::id(), false),
    ];

    Instruction::new_with_borsh(
        *program_id,
        &NFTPacksInstruction::AddCardToPack(args),
        accounts,
    )
}

/// Creates `AddVoucherToPack` instruction
#[allow(clippy::too_many_arguments)]
pub fn add_voucher_to_pack(
    program_id: &Pubkey,
    pack_set: &Pubkey,
    pack_voucher: &Pubkey,
    authority: &Pubkey,
    voucher_owner: &Pubkey,
    master_edition: &Pubkey,
    master_metadata: &Pubkey,
    mint: &Pubkey,
    source: &Pubkey,
    store: &Pubkey,
) -> Instruction {
    let accounts = vec![
        AccountMeta::new(*pack_set, false),
        AccountMeta::new(*pack_voucher, false),
        AccountMeta::new(*authority, true),
        AccountMeta::new_readonly(*voucher_owner, true),
        AccountMeta::new_readonly(*master_edition, false),
        AccountMeta::new_readonly(*master_metadata, false),
        AccountMeta::new_readonly(*mint, false),
        AccountMeta::new(*source, false),
        AccountMeta::new_readonly(*store, false),
        AccountMeta::new_readonly(sysvar::rent::id(), false),
        AccountMeta::new_readonly(system_program::id(), false),
        AccountMeta::new_readonly(spl_token::id(), false),
    ];

    Instruction::new_with_borsh(
        *program_id,
        &NFTPacksInstruction::AddVoucherToPack,
        accounts,
    )
}

/// Create `Activate` instruction
pub fn activate(program_id: &Pubkey, pack_set: &Pubkey, authority: &Pubkey) -> Instruction {
    let accounts = vec![
        AccountMeta::new(*pack_set, false),
        AccountMeta::new_readonly(*authority, true),
    ];

    Instruction::new_with_borsh(*program_id, &NFTPacksInstruction::Activate, accounts)
}

/// Create `Deactivate` instruction
pub fn deactivate(program_id: &Pubkey, pack_set: &Pubkey, authority: &Pubkey) -> Instruction {
    let accounts = vec![
        AccountMeta::new(*pack_set, false),
        AccountMeta::new_readonly(*authority, true),
    ];

    Instruction::new_with_borsh(*program_id, &NFTPacksInstruction::Deactivate, accounts)
}

/// Create `ClosePack` instruction
pub fn close_pack(program_id: &Pubkey, pack_set: &Pubkey, authority: &Pubkey) -> Instruction {
    let accounts = vec![
        AccountMeta::new(*pack_set, false),
        AccountMeta::new_readonly(*authority, true),
        AccountMeta::new_readonly(sysvar::clock::id(), false),
    ];

    Instruction::new_with_borsh(*program_id, &NFTPacksInstruction::ClosePack, accounts)
}

/// Create `ClaimPack` instruction
#[allow(clippy::too_many_arguments)]
pub fn claim_pack(
    program_id: &Pubkey,
    pack_set: &Pubkey,
    user_wallet: &Pubkey,
    voucher_mint: &Pubkey,
    user_token: &Pubkey,
    new_metadata: &Pubkey,
    new_edition: &Pubkey,
    master_edition: &Pubkey,
    new_mint: &Pubkey,
    new_mint_authority: &Pubkey,
    metadata: &Pubkey,
    metadata_mint: &Pubkey,
    index: u32,
) -> Instruction {
    let (proving_process, _) =
        find_proving_process_program_address(program_id, pack_set, user_wallet, voucher_mint);
    let (pack_card, _) = find_pack_card_program_address(program_id, pack_set, index);
    let (program_authority, _) = find_program_authority(program_id);

    let edition_number = (index as u64)
        .checked_div(mpl_token_metadata::state::EDITION_MARKER_BIT_SIZE)
        .unwrap();
    let as_string = edition_number.to_string();
    let (edition_mark_pda, _) = Pubkey::find_program_address(
        &[
            mpl_token_metadata::state::PREFIX.as_bytes(),
            mpl_token_metadata::id().as_ref(),
            metadata_mint.as_ref(),
            mpl_token_metadata::state::EDITION.as_bytes(),
            as_string.as_bytes(),
        ],
        &mpl_token_metadata::id(),
    );

    let accounts = vec![
        AccountMeta::new_readonly(*pack_set, false),
        AccountMeta::new(proving_process, false),
        AccountMeta::new(*user_wallet, true),
        AccountMeta::new_readonly(program_authority, false),
        AccountMeta::new(pack_card, false),
        AccountMeta::new(*user_token, false),
        AccountMeta::new(*new_metadata, false),
        AccountMeta::new(*new_edition, false),
        AccountMeta::new(*master_edition, false),
        AccountMeta::new(*new_mint, false),
        AccountMeta::new(*new_mint_authority, true),
        AccountMeta::new(*metadata, false),
        AccountMeta::new(*metadata_mint, false),
        AccountMeta::new(edition_mark_pda, false),
        AccountMeta::new_readonly(sysvar::rent::id(), false),
        AccountMeta::new_readonly(mpl_token_metadata::id(), false),
        AccountMeta::new_readonly(spl_token::id(), false),
        AccountMeta::new_readonly(system_program::id(), false),
    ];

    Instruction::new_with_borsh(
        *program_id,
        &NFTPacksInstruction::ClaimPack(ClaimPackArgs { index }),
        accounts,
    )
}

/// Create `TransferPackAuthority` instruction
pub fn transfer_pack_authority(
    program_id: &Pubkey,
    pack_set: &Pubkey,
    authority: &Pubkey,
    new_authority: &Pubkey,
) -> Instruction {
    let accounts = vec![
        AccountMeta::new(*pack_set, false),
        AccountMeta::new_readonly(*authority, true),
        AccountMeta::new_readonly(*new_authority, false),
    ];

    Instruction::new_with_borsh(
        *program_id,
        &NFTPacksInstruction::TransferPackAuthority,
        accounts,
    )
}

/// Create `DeletePack` instruction
pub fn delete_pack(
    program_id: &Pubkey,
    pack_set: &Pubkey,
    authority: &Pubkey,
    refunder: &Pubkey,
) -> Instruction {
    let accounts = vec![
        AccountMeta::new(*pack_set, false),
        AccountMeta::new_readonly(*authority, true),
        AccountMeta::new(*refunder, false),
    ];

    Instruction::new_with_borsh(*program_id, &NFTPacksInstruction::DeletePack, accounts)
}

/// Create `DeletePackCard` instruction
pub fn delete_pack_card(
    program_id: &Pubkey,
    pack_set: &Pubkey,
    pack_card: &Pubkey,
    authority: &Pubkey,
    refunder: &Pubkey,
    new_master_edition_owner: &Pubkey,
    token_account: &Pubkey,
) -> Instruction {
    let (program_authority, _) = find_program_authority(program_id);

    let accounts = vec![
        AccountMeta::new(*pack_set, false),
        AccountMeta::new(*pack_card, false),
        AccountMeta::new_readonly(*authority, true),
        AccountMeta::new(*refunder, false),
        AccountMeta::new(*new_master_edition_owner, false),
        AccountMeta::new(*token_account, false),
        AccountMeta::new_readonly(program_authority, false),
        AccountMeta::new_readonly(sysvar::rent::id(), false),
        AccountMeta::new_readonly(spl_token::id(), false),
    ];

    Instruction::new_with_borsh(*program_id, &NFTPacksInstruction::DeletePackCard, accounts)
}

/// Create `DeletePackVoucher` instruction
pub fn delete_pack_voucher(
    program_id: &Pubkey,
    pack_set: &Pubkey,
    pack_voucher: &Pubkey,
    authority: &Pubkey,
    refunder: &Pubkey,
) -> Instruction {
    let accounts = vec![
        AccountMeta::new(*pack_set, false),
        AccountMeta::new(*pack_voucher, false),
        AccountMeta::new_readonly(*authority, true),
        AccountMeta::new(*refunder, false),
    ];

    Instruction::new_with_borsh(
        *program_id,
        &NFTPacksInstruction::DeletePackVoucher,
        accounts,
    )
}

/// Create `EditPack` instruction
pub fn edit_pack(
    program_id: &Pubkey,
    pack_set: &Pubkey,
    authority: &Pubkey,
    args: EditPackSetArgs,
) -> Instruction {
    let accounts = vec![
        AccountMeta::new(*pack_set, false),
        AccountMeta::new_readonly(*authority, true),
    ];

    Instruction::new_with_borsh(*program_id, &NFTPacksInstruction::EditPack(args), accounts)
}

/// Create `RequestCardForRedeem` instruction
#[allow(clippy::too_many_arguments)]
pub fn request_card_for_redeem(
    program_id: &Pubkey,
    pack_set: &Pubkey,
    store: &Pubkey,
    edition: &Pubkey,
    edition_mint: &Pubkey,
    user_wallet: &Pubkey,
    user_token_acc: &Option<Pubkey>,
    index: u32,
) -> Instruction {
    let (proving_process, _) =
        find_proving_process_program_address(program_id, pack_set, user_wallet, edition_mint);

    let (pack_config, _) = find_pack_config_program_address(program_id, pack_set);

    let (pack_voucher, _) = find_pack_voucher_program_address(program_id, pack_set, index);

    let mut accounts = vec![
        AccountMeta::new(*pack_set, false),
        AccountMeta::new(pack_config, false),
        AccountMeta::new_readonly(*store, false),
        AccountMeta::new_readonly(*edition, false),
        AccountMeta::new(*edition_mint, false),
        AccountMeta::new_readonly(pack_voucher, false),
        AccountMeta::new(proving_process, false),
        AccountMeta::new(*user_wallet, true),
        AccountMeta::new_readonly(sysvar::slot_hashes::id(), false),
        AccountMeta::new_readonly(sysvar::clock::id(), false),
        AccountMeta::new_readonly(sysvar::rent::id(), false),
        AccountMeta::new_readonly(spl_token::id(), false),
        AccountMeta::new_readonly(system_program::id(), false),
    ];
    if let Some(user_token_account) = user_token_acc {
        accounts.push(AccountMeta::new(*user_token_account, false))
    }

    Instruction::new_with_borsh(
        *program_id,
        &NFTPacksInstruction::RequestCardForRedeem(RequestCardToRedeemArgs { index }),
        accounts,
    )
}

/// Create `CleanUp` instruction
#[allow(clippy::too_many_arguments)]
pub fn clean_up(program_id: &Pubkey, pack_set: &Pubkey) -> Instruction {
    let (pack_config, _) = find_pack_config_program_address(program_id, pack_set);

    let accounts = vec![
        AccountMeta::new(*pack_set, false),
        AccountMeta::new(pack_config, false),
    ];

    Instruction::new_with_borsh(*program_id, &NFTPacksInstruction::CleanUp, accounts)
}

/// Create `DeletePackConfig` instruction
pub fn delete_pack_config(
    program_id: &Pubkey,
    pack_set: &Pubkey,
    authority: &Pubkey,
    refunder: &Pubkey,
) -> Instruction {
    let (pack_config, _) = find_pack_config_program_address(program_id, pack_set);

    let accounts = vec![
        AccountMeta::new_readonly(*pack_set, false),
        AccountMeta::new(pack_config, false),
        AccountMeta::new(*refunder, false),
        AccountMeta::new_readonly(*authority, true),
    ];

    Instruction::new_with_borsh(
        *program_id,
        &NFTPacksInstruction::DeletePackConfig,
        accounts,
    )
}