1
1
use crate :: {
2
2
error:: MatchingEngineError ,
3
- state:: { AuctionConfig , Custodian , Proposal , ProposalAction } ,
3
+ state:: custodian:: * ,
4
+ state:: { AuctionConfig , Proposal , ProposalAction } ,
4
5
} ;
5
6
use anchor_lang:: prelude:: * ;
6
7
7
8
#[ derive( Accounts ) ]
8
9
pub struct UpdateAuctionParameters < ' info > {
9
10
#[ account( mut ) ]
10
- owner : Signer < ' info > ,
11
+ payer : Signer < ' info > ,
11
12
12
- #[ account(
13
- mut ,
14
- seeds = [ Custodian :: SEED_PREFIX ] ,
15
- bump = Custodian :: BUMP ,
16
- has_one = owner @ MatchingEngineError :: OwnerOnly ,
17
- ) ]
18
- custodian : Account < ' info , Custodian > ,
13
+ admin : OwnerMutCustodian < ' info > ,
19
14
20
15
#[ account(
21
16
mut ,
@@ -24,23 +19,25 @@ pub struct UpdateAuctionParameters<'info> {
24
19
proposal. id. to_be_bytes( ) . as_ref( ) ,
25
20
] ,
26
21
bump = proposal. bump,
27
- has_one = owner,
28
22
constraint = {
23
+ require_keys_eq!(
24
+ proposal. owner, admin. owner. key( )
25
+ ) ;
29
26
require!(
30
27
proposal. slot_enacted_at. is_none( ) ,
31
28
MatchingEngineError :: ProposalAlreadyEnacted
32
29
) ;
33
30
34
31
require!(
35
- Clock :: get( ) ? . slot >= proposal. slot_enact_delay,
32
+ Clock :: get( ) . unwrap ( ) . slot >= proposal. slot_enact_delay,
36
33
MatchingEngineError :: ProposalDelayNotExpired
37
34
) ;
38
35
39
36
match & proposal. action {
40
37
ProposalAction :: UpdateAuctionParameters { id, .. } => {
41
38
require_eq!(
42
39
* id,
43
- custodian. auction_config_id + 1 ,
40
+ admin . custodian. auction_config_id + 1 ,
44
41
MatchingEngineError :: AuctionConfigMismatch
45
42
) ;
46
43
} ,
@@ -54,11 +51,11 @@ pub struct UpdateAuctionParameters<'info> {
54
51
55
52
#[ account(
56
53
init,
57
- payer = owner ,
54
+ payer = payer ,
58
55
space = 8 + AuctionConfig :: INIT_SPACE ,
59
56
seeds = [
60
57
AuctionConfig :: SEED_PREFIX ,
61
- ( custodian. auction_config_id + 1 ) . to_be_bytes( ) . as_ref( )
58
+ ( admin . custodian. auction_config_id + 1 ) . to_be_bytes( ) . as_ref( )
62
59
] ,
63
60
bump,
64
61
) ]
@@ -78,10 +75,13 @@ pub fn update_auction_parameters(ctx: Context<UpdateAuctionParameters>) -> Resul
78
75
}
79
76
80
77
// Update the auction config ID.
81
- ctx. accounts . custodian . auction_config_id += 1 ;
78
+ ctx. accounts . admin . custodian . auction_config_id += 1 ;
82
79
83
80
// Set the slot enacted at so it cannot be replayed.
84
- ctx. accounts . proposal . slot_enacted_at = Some ( Clock :: get ( ) . map ( |clock| clock. slot ) ?) ;
81
+ ctx. accounts . proposal . slot_enacted_at = Some ( Clock :: get ( ) . unwrap ( ) . slot ) ;
82
+
83
+ // Uptick the proposal ID so that someone can create a new proposal again.
84
+ ctx. accounts . admin . custodian . next_proposal_id += 1 ;
85
85
86
86
// Done.
87
87
Ok ( ( ) )
0 commit comments