Skip to content

Commit 5e79d9b

Browse files
committed
Address a5-pickle feedback
1 parent e5887ad commit 5e79d9b

File tree

4 files changed

+54
-39
lines changed

4 files changed

+54
-39
lines changed

solana/programs/matching-engine/src/processor/admin/update/auction_parameters.rs

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::{
22
error::MatchingEngineError,
3-
state::{AuctionConfig, Custodian, Proposal, ProposalAction},
3+
state::custodian::*,
4+
state::{AuctionConfig, Proposal, ProposalAction},
45
};
56
use anchor_lang::prelude::*;
67

@@ -9,13 +10,7 @@ pub struct UpdateAuctionParameters<'info> {
910
#[account(mut)]
1011
payer: Signer<'info>,
1112

12-
owner: Signer<'info>,
13-
14-
#[account(
15-
mut,
16-
has_one = owner @ MatchingEngineError::OwnerOnly,
17-
)]
18-
custodian: Account<'info, Custodian>,
13+
admin: OwnerMutCustodian<'info>,
1914

2015
#[account(
2116
mut,
@@ -24,8 +19,11 @@ pub struct UpdateAuctionParameters<'info> {
2419
proposal.id.to_be_bytes().as_ref(),
2520
],
2621
bump = proposal.bump,
27-
has_one = owner,
2822
constraint = {
23+
require!(
24+
proposal.owner == admin.owner.key(),
25+
MatchingEngineError::OwnerOnly
26+
);
2927
require!(
3028
proposal.slot_enacted_at.is_none(),
3129
MatchingEngineError::ProposalAlreadyEnacted
@@ -40,7 +38,7 @@ pub struct UpdateAuctionParameters<'info> {
4038
ProposalAction::UpdateAuctionParameters { id, .. } => {
4139
require_eq!(
4240
*id,
43-
custodian.auction_config_id + 1,
41+
admin.custodian.auction_config_id + 1,
4442
MatchingEngineError::AuctionConfigMismatch
4543
);
4644
},
@@ -58,7 +56,7 @@ pub struct UpdateAuctionParameters<'info> {
5856
space = 8 + AuctionConfig::INIT_SPACE,
5957
seeds = [
6058
AuctionConfig::SEED_PREFIX,
61-
(custodian.auction_config_id + 1).to_be_bytes().as_ref()
59+
(admin.custodian.auction_config_id + 1).to_be_bytes().as_ref()
6260
],
6361
bump,
6462
)]
@@ -78,13 +76,13 @@ pub fn update_auction_parameters(ctx: Context<UpdateAuctionParameters>) -> Resul
7876
}
7977

8078
// Update the auction config ID.
81-
ctx.accounts.custodian.auction_config_id += 1;
79+
ctx.accounts.admin.custodian.auction_config_id += 1;
8280

8381
// Set the slot enacted at so it cannot be replayed.
8482
ctx.accounts.proposal.slot_enacted_at = Some(Clock::get().unwrap().slot);
8583

8684
// Uptick the proposal ID so that someone can create a new proposal again.
87-
ctx.accounts.custodian.next_proposal_id += 1;
85+
ctx.accounts.admin.custodian.next_proposal_id += 1;
8886

8987
// Done.
9088
Ok(())

solana/target/idl/matching_engine.json

+13-8
Original file line numberDiff line numberDiff line change
@@ -1415,14 +1415,19 @@
14151415
"isSigner": true
14161416
},
14171417
{
1418-
"name": "owner",
1419-
"isMut": false,
1420-
"isSigner": true
1421-
},
1422-
{
1423-
"name": "custodian",
1424-
"isMut": true,
1425-
"isSigner": false
1418+
"name": "admin",
1419+
"accounts": [
1420+
{
1421+
"name": "owner",
1422+
"isMut": false,
1423+
"isSigner": true
1424+
},
1425+
{
1426+
"name": "custodian",
1427+
"isMut": true,
1428+
"isSigner": false
1429+
}
1430+
]
14261431
},
14271432
{
14281433
"name": "proposal",

solana/target/types/matching_engine.ts

+26-16
Original file line numberDiff line numberDiff line change
@@ -1415,14 +1415,19 @@ export type MatchingEngine = {
14151415
"isSigner": true
14161416
},
14171417
{
1418-
"name": "owner",
1419-
"isMut": false,
1420-
"isSigner": true
1421-
},
1422-
{
1423-
"name": "custodian",
1424-
"isMut": true,
1425-
"isSigner": false
1418+
"name": "admin",
1419+
"accounts": [
1420+
{
1421+
"name": "owner",
1422+
"isMut": false,
1423+
"isSigner": true
1424+
},
1425+
{
1426+
"name": "custodian",
1427+
"isMut": true,
1428+
"isSigner": false
1429+
}
1430+
]
14261431
},
14271432
{
14281433
"name": "proposal",
@@ -4201,14 +4206,19 @@ export const IDL: MatchingEngine = {
42014206
"isSigner": true
42024207
},
42034208
{
4204-
"name": "owner",
4205-
"isMut": false,
4206-
"isSigner": true
4207-
},
4208-
{
4209-
"name": "custodian",
4210-
"isMut": true,
4211-
"isSigner": false
4209+
"name": "admin",
4210+
"accounts": [
4211+
{
4212+
"name": "owner",
4213+
"isMut": false,
4214+
"isSigner": true
4215+
},
4216+
{
4217+
"name": "custodian",
4218+
"isMut": true,
4219+
"isSigner": false
4220+
}
4221+
]
42124222
},
42134223
{
42144224
"name": "proposal",

solana/ts/src/matchingEngine/index.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,10 @@ export class MatchingEngineProgram {
548548
.updateAuctionParameters()
549549
.accounts({
550550
payer: inputPayer ?? owner,
551-
owner,
552-
custodian: inputCustodian ?? this.custodianAddress(),
551+
admin: {
552+
owner,
553+
custodian: inputCustodian ?? this.custodianAddress(),
554+
},
553555
proposal: inputProposal ?? (await this.proposalAddress()),
554556
auctionConfig,
555557
})

0 commit comments

Comments
 (0)