-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ProposalConfigV0.authority and update_proposal_config_v0 instruction
- Loading branch information
1 parent
092d6e5
commit 0ccbe2e
Showing
7 changed files
with
186 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
pub mod initialize_proposal_config_v0; | ||
pub mod initialize_proposal_v0; | ||
pub mod update_proposal_config_v0; | ||
pub mod update_state_v0; | ||
pub mod vote_v0; | ||
|
||
pub use initialize_proposal_config_v0::*; | ||
pub use initialize_proposal_v0::*; | ||
pub use update_proposal_config_v0::*; | ||
pub use update_state_v0::*; | ||
pub use vote_v0::*; |
42 changes: 42 additions & 0 deletions
42
programs/proposal/src/instructions/update_proposal_config_v0.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use crate::state::*; | ||
use anchor_lang::prelude::*; | ||
|
||
#[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] | ||
pub struct UpdateProposalConfigArgsV0 { | ||
pub vote_controller: Option<Pubkey>, | ||
pub state_controller: Option<Pubkey>, | ||
pub on_vote_hook: Option<Pubkey>, | ||
pub authority: Option<Pubkey>, | ||
} | ||
|
||
#[derive(Accounts)] | ||
pub struct UpdateProposalConfigV0<'info> { | ||
#[account(mut)] | ||
pub payer: Signer<'info>, | ||
#[account( | ||
mut, | ||
has_one = authority, | ||
)] | ||
pub proposal_config: Box<Account<'info, ProposalConfigV0>>, | ||
pub authority: Signer<'info>, | ||
} | ||
|
||
pub fn handler( | ||
ctx: Context<UpdateProposalConfigV0>, | ||
args: UpdateProposalConfigArgsV0, | ||
) -> Result<()> { | ||
if let Some(vote_controller) = args.vote_controller { | ||
ctx.accounts.proposal_config.vote_controller = vote_controller; | ||
} | ||
if let Some(state_controller) = args.state_controller { | ||
ctx.accounts.proposal_config.state_controller = state_controller; | ||
} | ||
if let Some(on_vote_hook) = args.on_vote_hook { | ||
ctx.accounts.proposal_config.on_vote_hook = on_vote_hook; | ||
} | ||
if let Some(authority) = args.authority { | ||
ctx.accounts.proposal_config.authority = authority; | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters