1
1
use anchor_lang:: prelude:: * ;
2
2
use anchor_spl:: token_interface:: { Mint , TokenAccount , TokenInterface } ;
3
3
4
- use crate :: context:: { VESTING_BALANCE_SEED , VESTING_CONFIG_SEED , VEST_SEED } ;
4
+ use crate :: context:: { VESTING_BALANCE_SEED , VESTING_CONFIG_SEED , VEST_SEED , CONFIG_SEED } ;
5
5
use crate :: error:: VestingError ;
6
6
use crate :: state:: { Vesting , VestingBalance , VestingConfig } ;
7
+ use crate :: state:: global_config:: GlobalConfig ;
7
8
8
9
#[ derive( Accounts ) ]
9
10
#[ instruction( maturation: i64 ) ]
10
11
pub struct CreateVesting < ' info > {
11
- #[ account( mut ) ]
12
+ #[ account(
13
+ mut ,
14
+ constraint = global_config. vesting_admin == admin. key( )
15
+ @ VestingError :: InvalidVestingAdmin
16
+ ) ]
12
17
admin : Signer < ' info > ,
13
18
mint : InterfaceAccount < ' info , Mint > ,
14
19
#[ account(
@@ -19,9 +24,8 @@ pub struct CreateVesting<'info> {
19
24
#[ account(
20
25
mut ,
21
26
constraint = !config. finalized @ VestingError :: VestingFinalized , // Vesting cannot be cancelled after vest is finalized
22
- has_one = admin, // This check is arbitrary, as mint is baked into the PDA
23
27
has_one = mint, // This check is arbitrary, as mint is baked into the PDA
24
- seeds = [ VESTING_CONFIG_SEED . as_bytes( ) , admin . key ( ) . as_ref ( ) , mint. key( ) . as_ref( ) , config. seed. to_le_bytes( ) . as_ref( ) ] ,
28
+ seeds = [ VESTING_CONFIG_SEED . as_bytes( ) , mint. key( ) . as_ref( ) , config. seed. to_le_bytes( ) . as_ref( ) ] ,
25
29
bump = config. bump
26
30
) ]
27
31
config : Account < ' info , VestingConfig > ,
@@ -39,6 +43,11 @@ pub struct CreateVesting<'info> {
39
43
bump = vesting_balance. bump
40
44
) ]
41
45
vesting_balance : Account < ' info , VestingBalance > ,
46
+ #[ account(
47
+ seeds = [ CONFIG_SEED . as_bytes( ) ] ,
48
+ bump = global_config. bump,
49
+ ) ]
50
+ pub global_config : Box < Account < ' info , GlobalConfig > > ,
42
51
token_program : Interface < ' info , TokenInterface > ,
43
52
system_program : Program < ' info , System > ,
44
53
}
0 commit comments