forked from otter-sec/anchor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontext.rs
More file actions
746 lines (683 loc) · 22 KB
/
Copy pathcontext.rs
File metadata and controls
746 lines (683 loc) · 22 KB
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
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
use crate::account::*;
use anchor_lang::prelude::*;
use anchor_spl::associated_token::AssociatedToken;
use anchor_spl::token::{Mint, Token, TokenAccount};
use anchor_spl::token_interface::{Mint as MintInterface, TokenAccount as TokenAccountInterface};
#[derive(Accounts)]
pub struct TestTokenSeedsInit<'info> {
#[account(
init,
seeds = [b"my-mint-seed".as_ref()],
bump,
payer = authority,
mint::decimals = 6,
mint::authority = authority,
)]
pub mint: Option<Account<'info, Mint>>,
#[account(
init,
seeds = [b"my-token-seed".as_ref()],
bump,
payer = authority,
token::mint = mint,
token::authority = authority,
)]
pub my_pda: Option<Account<'info, TokenAccount>>,
#[account(mut)]
/// CHECK:
pub authority: Option<AccountInfo<'info>>,
pub system_program: Option<Program<'info, System>>,
pub token_program: Option<Program<'info, Token>>,
}
#[derive(Accounts)]
pub struct TestInitAssociatedToken<'info> {
#[account(
init,
associated_token::mint = mint,
payer = payer,
associated_token::authority = payer,
)]
pub token: Option<Account<'info, TokenAccount>>,
pub mint: Option<Account<'info, Mint>>,
#[account(mut)]
pub payer: Option<Signer<'info>>,
pub system_program: Option<Program<'info, System>>,
pub token_program: Option<Program<'info, Token>>,
pub associated_token_program: Option<Program<'info, AssociatedToken>>,
}
#[derive(Accounts)]
pub struct TestInitAssociatedTokenWithTokenProgram<'info> {
#[account(init,
payer = payer,
associated_token::mint = mint,
associated_token::authority = payer,
associated_token::token_program = associated_token_token_program,
)]
pub token: Option<InterfaceAccount<'info, TokenAccountInterface>>,
pub mint: Option<InterfaceAccount<'info, MintInterface>>,
#[account(mut)]
pub payer: Option<Signer<'info>>,
pub system_program: Option<Program<'info, System>>,
/// CHECK: ignore
pub associated_token_token_program: Option<AccountInfo<'info>>,
pub associated_token_program: Option<Program<'info, AssociatedToken>>,
}
#[derive(Accounts)]
pub struct TestValidateAssociatedToken<'info> {
#[account(
associated_token::mint = mint,
associated_token::authority = wallet,
)]
pub token: Option<Account<'info, TokenAccount>>,
pub mint: Option<Account<'info, Mint>>,
/// CHECK:
pub wallet: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
#[instruction(nonce: u8)]
pub struct TestInstructionConstraint<'info> {
#[account(
seeds = [b"my-seed", my_account.as_ref().unwrap().key.as_ref()],
bump = nonce,
)]
/// CHECK:
pub my_pda: Option<AccountInfo<'info>>,
/// CHECK:
pub my_account: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
#[instruction(domain: String, seed: Vec<u8>, bump: u8)]
pub struct TestPdaInit<'info> {
#[account(
init,
seeds = [b"my-seed", domain.as_bytes(), foo.as_ref().unwrap().key.as_ref(), &seed],
bump,
payer = my_payer,
space = DataU16::LEN + 8
)]
pub my_pda: Option<Account<'info, DataU16>>,
#[account(mut)]
pub my_payer: Option<Signer<'info>>,
/// CHECK:
pub foo: Option<AccountInfo<'info>>,
pub system_program: Option<Program<'info, System>>,
}
#[derive(Accounts)]
pub struct TestPdaInitZeroCopy<'info> {
#[account(
init,
seeds = [b"my-seed".as_ref()],
bump,
payer = my_payer,
space = DataZeroCopy::LEN + 8
)]
pub my_pda: Option<AccountLoader<'info, DataZeroCopy>>,
#[account(mut)]
pub my_payer: Option<Signer<'info>>,
pub system_program: Option<Program<'info, System>>,
}
#[derive(Accounts)]
pub struct TestPdaMutZeroCopy<'info> {
#[account(
mut,
seeds = [b"my-seed".as_ref()],
bump = my_pda.load()?.bump,
)]
pub my_pda: Option<AccountLoader<'info, DataZeroCopy>>,
/// CHECK:
pub my_payer: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
pub struct Initialize<'info> {
#[account(zero)]
pub data: Option<Account<'info, Data>>,
}
#[derive(Accounts)]
pub struct InitializeSkipRentExempt<'info> {
#[account(zero, rent_exempt = skip)]
pub data: Option<Account<'info, Data>>,
}
#[derive(Accounts)]
pub struct InitializeNoRentExempt<'info> {
/// CHECK:
pub data: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
pub struct TestOwner<'info> {
#[account(owner = *misc.key)]
/// CHECK:
pub data: Option<AccountInfo<'info>>,
/// CHECK:
pub misc: AccountInfo<'info>,
}
#[derive(Accounts)]
pub struct TestExecutable<'info> {
#[account(executable)]
/// CHECK:
pub program: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
pub struct TestClose<'info> {
#[account(mut, close = sol_dest)]
pub data: Option<Account<'info, Data>>,
/// CHECK:
sol_dest: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
pub struct TestCloseTwice<'info> {
#[account(mut, close = sol_dest)]
pub data: Option<Account<'info, Data>>,
/// CHECK:
pub sol_dest: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
pub struct TestCloseMut<'info> {
#[account(mut)]
pub data: Option<Account<'info, Data>>,
/// CHECK:
pub sol_dest: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
pub struct TestSimulate {}
#[derive(Accounts)]
pub struct TestCompositePayer<'info> {
pub composite: TestInit<'info>,
#[account(init, payer = payer.as_ref().unwrap(), space = Data::LEN + 8)]
pub data: Option<Account<'info, Data>>,
pub payer: Option<Signer<'info>>,
pub system_program: Option<Program<'info, System>>,
}
#[derive(Accounts)]
pub struct TestInit<'info> {
#[account(init, payer = payer, space = DataI8::LEN + 8)]
pub data: Option<Account<'info, DataI8>>,
#[account(mut)]
pub payer: Option<Signer<'info>>,
pub system_program: Option<Program<'info, System>>,
}
#[derive(Accounts)]
pub struct TestInitZeroCopy<'info> {
#[account(init, payer = payer, space = DataZeroCopy::LEN + 8)]
pub data: Option<AccountLoader<'info, DataZeroCopy>>,
#[account(mut)]
pub payer: Option<Signer<'info>>,
pub system_program: Option<Program<'info, System>>,
}
#[derive(Accounts)]
pub struct TestInitMint<'info> {
#[account(init, mint::decimals = 6, mint::authority = payer, mint::freeze_authority = payer, payer = payer, )]
pub mint: Option<Account<'info, Mint>>,
#[account(mut)]
pub payer: Option<Signer<'info>>,
pub system_program: Option<Program<'info, System>>,
pub token_program: Option<Program<'info, Token>>,
}
#[derive(Accounts)]
pub struct TestInitMintWithTokenProgram<'info> {
#[account(init,
payer = payer,
mint::decimals = 6,
mint::authority = payer,
mint::freeze_authority = payer,
mint::token_program = mint_token_program,
)]
pub mint: Option<InterfaceAccount<'info, MintInterface>>,
#[account(mut)]
pub payer: Option<Signer<'info>>,
pub system_program: Option<Program<'info, System>>,
/// CHECK: ignore
pub mint_token_program: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
pub struct TestInitToken<'info> {
#[account(init, token::mint = mint, token::authority = payer, payer = payer, )]
pub token: Option<Account<'info, TokenAccount>>,
pub mint: Option<Account<'info, Mint>>,
#[account(mut)]
pub payer: Option<Signer<'info>>,
pub system_program: Option<Program<'info, System>>,
pub token_program: Option<Program<'info, Token>>,
}
#[derive(Accounts)]
pub struct TestInitTokenWithTokenProgram<'info> {
#[account(init,
payer = payer,
token::mint = mint,
token::authority = payer,
token::token_program = token_token_program,
)]
pub token: Option<Account<'info, TokenAccount>>,
pub mint: Option<Account<'info, Mint>>,
#[account(mut)]
pub payer: Option<Signer<'info>>,
pub system_program: Option<Program<'info, System>>,
/// CHECK: ignore
pub token_token_program: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
pub struct TestFetchAll<'info> {
#[account(init, payer = authority, space = DataWithFilter::LEN + 8)]
pub data: Option<Account<'info, DataWithFilter>>,
#[account(mut)]
pub authority: Option<Signer<'info>>,
pub system_program: Option<Program<'info, System>>,
}
#[derive(Accounts)]
pub struct TestInitWithEmptySeeds<'info> {
#[account(init, seeds = [], bump, payer = authority, space = Data::LEN + 8)]
pub pda: Option<Account<'info, Data>>,
#[account(mut)]
pub authority: Option<Signer<'info>>,
pub system_program: Option<Program<'info, System>>,
}
#[derive(Accounts)]
pub struct TestEmptySeedsConstraint<'info> {
#[account(seeds = [], bump)]
/// CHECK:
pub pda: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
pub struct InitWithSpace<'info> {
#[account(init, payer = payer, space = DataU16::LEN + 8)]
pub data: Option<Account<'info, DataU16>>,
#[account(mut)]
pub payer: Option<Signer<'info>>,
pub system_program: Option<Program<'info, System>>,
}
#[derive(Accounts)]
pub struct TestInitIfNeeded<'info> {
// intentionally using more space (+500) to check whether space is checked when using init_if_needed
#[account(init_if_needed, payer = payer, space = DataU16::LEN + 8 + 500)]
pub data: Option<Account<'info, DataU16>>,
#[account(mut)]
pub payer: Option<Signer<'info>>,
pub system_program: Option<Program<'info, System>>,
}
#[derive(Accounts)]
pub struct TestInitIfNeededChecksOwner<'info> {
#[account(init_if_needed, payer = payer, space = 100, owner = *owner.key, seeds = [b"hello"], bump)]
/// CHECK:
pub data: Option<UncheckedAccount<'info>>,
#[account(mut)]
pub payer: Option<Signer<'info>>,
pub system_program: Option<Program<'info, System>>,
/// CHECK:
pub owner: AccountInfo<'info>,
}
#[derive(Accounts)]
#[instruction(seed_data: String)]
pub struct TestInitIfNeededChecksSeeds<'info> {
#[account(init_if_needed, payer = payer, space = 100, seeds = [seed_data.as_bytes()], bump)]
/// CHECK:
pub data: Option<UncheckedAccount<'info>>,
#[account(mut)]
pub payer: Option<Signer<'info>>,
pub system_program: Option<Program<'info, System>>,
}
#[derive(Accounts)]
#[instruction(decimals: u8)]
pub struct TestInitMintIfNeeded<'info> {
#[account(init_if_needed, mint::decimals = decimals, mint::authority = mint_authority, mint::freeze_authority = freeze_authority, payer = payer)]
pub mint: Option<Account<'info, Mint>>,
#[account(mut)]
pub payer: Option<Signer<'info>>,
pub system_program: Option<Program<'info, System>>,
pub token_program: Option<Program<'info, Token>>,
/// CHECK:
pub mint_authority: Option<AccountInfo<'info>>,
/// CHECK:
pub freeze_authority: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
pub struct TestInitMintIfNeededWithTokenProgram<'info> {
#[account(init_if_needed,
payer = payer,
mint::decimals = 6,
mint::authority = mint_authority,
mint::freeze_authority = freeze_authority,
mint::token_program = mint_token_program,
)]
pub mint: Option<Account<'info, Mint>>,
#[account(mut)]
pub payer: Option<Signer<'info>>,
pub system_program: Option<Program<'info, System>>,
/// CHECK: ignore
pub mint_token_program: Option<AccountInfo<'info>>,
/// CHECK: ignore
pub mint_authority: Option<AccountInfo<'info>>,
/// CHECK: ignore
pub freeze_authority: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
pub struct TestInitTokenIfNeeded<'info> {
#[account(init_if_needed, token::mint = mint, token::authority = authority, payer = payer, )]
pub token: Option<Account<'info, TokenAccount>>,
pub mint: Option<Account<'info, Mint>>,
#[account(mut)]
pub payer: Option<Signer<'info>>,
pub system_program: Option<Program<'info, System>>,
pub token_program: Option<Program<'info, Token>>,
/// CHECK:
pub authority: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
pub struct TestInitTokenIfNeededWithTokenProgram<'info> {
#[account(init_if_needed,
payer = payer,
token::mint = mint,
token::authority = authority,
token::token_program = token_token_program
)]
pub token: Option<Account<'info, TokenAccount>>,
pub mint: Option<Account<'info, Mint>>,
#[account(mut)]
pub payer: Option<Signer<'info>>,
pub system_program: Option<Program<'info, System>>,
/// CHECK: ignore
pub token_token_program: Option<AccountInfo<'info>>,
/// CHECK:
pub authority: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
pub struct TestInitAssociatedTokenIfNeeded<'info> {
#[account(init_if_needed,
payer = payer,
associated_token::mint = mint,
associated_token::authority = authority
)]
pub token: Option<Account<'info, TokenAccount>>,
pub mint: Option<Account<'info, Mint>>,
#[account(mut)]
pub payer: Option<Signer<'info>>,
pub system_program: Option<Program<'info, System>>,
pub token_program: Option<Program<'info, Token>>,
pub associated_token_program: Option<Program<'info, AssociatedToken>>,
/// CHECK:
pub authority: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
pub struct TestInitAssociatedTokenIfNeededWithTokenProgram<'info> {
#[account(init_if_needed,
payer = payer,
associated_token::mint = mint,
associated_token::authority = authority,
associated_token::token_program = associated_token_token_program,
)]
pub token: Option<InterfaceAccount<'info, TokenAccountInterface>>,
pub mint: Option<InterfaceAccount<'info, MintInterface>>,
#[account(mut)]
pub payer: Option<Signer<'info>>,
pub system_program: Option<Program<'info, System>>,
/// CHECK: ignore
pub associated_token_token_program: Option<AccountInfo<'info>>,
pub associated_token_program: Option<Program<'info, AssociatedToken>>,
/// CHECK: ignore
pub authority: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
pub struct TestMultidimensionalArray<'info> {
#[account(zero)]
pub data: Option<Account<'info, DataMultidimensionalArray>>,
}
#[derive(Accounts)]
pub struct TestConstArraySize<'info> {
#[account(zero)]
pub data: Option<Account<'info, DataConstArraySize>>,
}
#[derive(Accounts)]
pub struct TestConstIxDataSize<'info> {
#[account(zero)]
pub data: Option<Account<'info, DataConstArraySize>>,
}
#[derive(Accounts)]
pub struct TestMultidimensionalArrayConstSizes<'info> {
#[account(zero)]
pub data: Option<Account<'info, DataMultidimensionalArrayConstSizes>>,
}
#[derive(Accounts)]
pub struct NoRentExempt<'info> {
/// CHECK:
pub data: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
pub struct EnforceRentExempt<'info> {
#[account(rent_exempt = enforce)]
/// CHECK:
pub data: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
pub struct InitDecreaseLamports<'info> {
#[account(init, payer = user, space = 1000)]
/// CHECK:
pub data: Option<AccountInfo<'info>>,
#[account(mut)]
pub user: Option<Signer<'info>>,
pub system_program: Option<Program<'info, System>>,
}
#[derive(Accounts)]
pub struct InitIfNeededChecksRentExemption<'info> {
#[account(init_if_needed, payer = user, space = 1000)]
/// CHECK:
pub data: Option<AccountInfo<'info>>,
#[account(mut)]
pub user: Option<Signer<'info>>,
pub system_program: Option<Program<'info, System>>,
}
#[derive(Accounts)]
#[instruction(bump: u8, second_bump: u8)]
pub struct TestProgramIdConstraint<'info> {
// not a real associated token account
// just deriving like this for testing purposes
#[account(seeds = [b"seed"], bump = bump, seeds::program = anchor_spl::associated_token::ID)]
/// CHECK:
first: Option<AccountInfo<'info>>,
#[account(seeds = [b"seed"], bump = second_bump, seeds::program = crate::ID)]
/// CHECK:
second: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
pub struct TestProgramIdConstraintUsingFindPda<'info> {
// not a real associated token account
// just deriving like this for testing purposes
#[account(seeds = [b"seed"], bump, seeds::program = anchor_spl::associated_token::ID)]
/// CHECK:
first: Option<AccountInfo<'info>>,
#[account(seeds = [b"seed"], bump, seeds::program = crate::ID)]
/// CHECK:
second: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
pub struct TestUnsafeFieldSafetyErrors<'info> {
#[doc = "test"]
/// CHECK:
pub data: Option<UncheckedAccount<'info>>,
#[account(mut)]
/// CHECK:
pub data_two: Option<UncheckedAccount<'info>>,
#[account(
seeds = [b"my-seed", signer.as_ref().unwrap().key.as_ref()],
bump
)]
/// CHECK:
pub data_three: Option<UncheckedAccount<'info>>,
/// CHECK:
pub data_four: Option<UncheckedAccount<'info>>,
pub signer: Option<Signer<'info>>,
pub system_program: Option<Program<'info, System>>,
}
#[derive(Accounts)]
pub struct TestConstraintToken<'info> {
#[account(
token::mint = mint,
token::authority = payer
)]
pub token: Option<Account<'info, TokenAccount>>,
pub mint: Option<Account<'info, Mint>>,
pub payer: Option<Signer<'info>>,
}
#[derive(Accounts)]
pub struct TestAuthorityConstraint<'info> {
#[account(
token::mint = mint,
token::authority = fake_authority
)]
pub token: Option<Account<'info, TokenAccount>>,
pub mint: Option<Account<'info, Mint>>,
pub fake_authority: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
pub struct TestOnlyAuthorityConstraint<'info> {
#[account(
token::authority = payer
)]
pub token: Option<Account<'info, TokenAccount>>,
pub mint: Option<Account<'info, Mint>>,
pub payer: Option<Signer<'info>>,
}
#[derive(Accounts)]
pub struct TestOnlyTokenProgramConstraint<'info> {
#[account(
token::token_program = token_token_program
)]
pub token: Option<Account<'info, TokenAccount>>,
pub token_token_program: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
pub struct TestOnlyMintConstraint<'info> {
#[account(
token::mint = mint,
)]
pub token: Option<Account<'info, TokenAccount>>,
pub mint: Option<Account<'info, Mint>>,
}
#[derive(Accounts)]
#[instruction(decimals: u8)]
pub struct TestMintConstraint<'info> {
#[account(
mint::decimals = decimals,
mint::authority = mint_authority,
mint::freeze_authority = freeze_authority
)]
pub mint: Option<Account<'info, Mint>>,
pub mint_authority: Option<AccountInfo<'info>>,
pub freeze_authority: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
#[instruction(decimals: u8)]
pub struct TestMintOnlyDecimalsConstraint<'info> {
#[account(
mint::decimals = decimals,
)]
pub mint: Option<Account<'info, Mint>>,
}
#[derive(Accounts)]
pub struct TestMintAuthorityConstraint<'info> {
#[account(
mint::authority = mint_authority,
mint::freeze_authority = freeze_authority
)]
pub mint: Option<Account<'info, Mint>>,
pub mint_authority: Option<AccountInfo<'info>>,
pub freeze_authority: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
pub struct TestMintOneAuthorityConstraint<'info> {
#[account(
mint::authority = mint_authority,
)]
pub mint: Option<Account<'info, Mint>>,
pub mint_authority: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
#[instruction(decimals: u8)]
pub struct TestMintMissMintAuthConstraint<'info> {
#[account(
mint::decimals = decimals,
mint::freeze_authority = freeze_authority,
)]
pub mint: Option<Account<'info, Mint>>,
pub freeze_authority: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
pub struct TestMintOnlyTokenProgramConstraint<'info> {
#[account(
mint::token_program = mint_token_program,
)]
pub mint: Option<Account<'info, Mint>>,
/// CHECK: ignore
pub mint_token_program: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
pub struct TestAssociatedToken<'info> {
#[account(
associated_token::mint = mint,
associated_token::authority = authority,
)]
pub token: Option<Account<'info, TokenAccount>>,
pub mint: Option<Account<'info, Mint>>,
pub authority: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
pub struct TestAssociatedTokenWithTokenProgramConstraint<'info> {
#[account(
associated_token::mint = mint,
associated_token::authority = authority,
associated_token::token_program = associated_token_token_program,
)]
pub token: Option<InterfaceAccount<'info, TokenAccountInterface>>,
pub mint: InterfaceAccount<'info, MintInterface>,
/// CHECK: ignore
pub authority: AccountInfo<'info>,
/// CHECK: ignore
pub associated_token_token_program: Option<AccountInfo<'info>>,
}
#[derive(Accounts)]
pub struct InitManyAssociatedTokenAccounts<'info> {
#[account(
init,
payer = user,
mint::authority = user,
mint::decimals = 9,
)]
pub mint: Account<'info, Mint>,
#[account(
init,
payer = user,
associated_token::authority = user,
associated_token::mint = mint,
)]
pub ata1: Account<'info, TokenAccount>,
#[account(
init,
payer = user,
associated_token::authority = system_program,
associated_token::mint = mint,
)]
pub ata2: Account<'info, TokenAccount>,
#[account(
init,
payer = user,
associated_token::authority = token_program,
associated_token::mint = mint,
)]
pub ata3: Account<'info, TokenAccount>,
#[account(
init,
payer = user,
associated_token::authority = associated_token_program,
associated_token::mint = mint,
)]
pub ata4: Account<'info, TokenAccount>,
#[account(
init,
payer = user,
associated_token::authority = mint,
associated_token::mint = mint,
)]
pub ata5: Account<'info, TokenAccount>,
#[account(mut)]
pub user: Signer<'info>,
pub system_program: Program<'info, System>,
pub token_program: Program<'info, Token>,
pub associated_token_program: Program<'info, AssociatedToken>,
}