Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ incremental = false
codegen-units = 1

[workspace.dependencies]
anchor-lang = { version = "0.31.0", features = ["init-if-needed"] }
anchor-spl = { version = "0.31.0", features = ["token", "metadata"] }
anchor-lang = { version = "0.31.1", features = ["init-if-needed"] }
anchor-spl = { version = "0.31.1", features = ["token", "metadata"] }

2 changes: 2 additions & 0 deletions programs/proposal/src/instructions/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
pub mod initialize_proposal_config_v0;
pub mod initialize_proposal_v0;
pub mod update_proposal_config_v0;
pub mod update_proposal_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_proposal_v0::*;
pub use update_state_v0::*;
pub use vote_v0::*;
40 changes: 40 additions & 0 deletions programs/proposal/src/instructions/update_proposal_v0.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
use anchor_lang::prelude::*;

use crate::state::*;

#[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)]
pub struct UpdateProposalArgsV0 {
pub name: Option<String>,
pub uri: Option<String>,
pub tags: Option<Vec<String>>,
}

#[derive(Accounts)]
pub struct UpdateProposalV0<'info> {
#[account(
mut,
has_one = owner,
constraint = match proposal.state {
// Only allow updating name, uri, and tags if proposal has no votes
ProposalState::Voting { .. } => proposal.choices.iter().all(|choice| choice.weight == 0),
ProposalState::Resolved { .. } => false,
_ => true
}
)]
pub proposal: Box<Account<'info, ProposalV0>>,
pub owner: Signer<'info>,
}

pub fn handler(ctx: Context<UpdateProposalV0>, args: UpdateProposalArgsV0) -> Result<()> {
if let Some(name) = args.name {
ctx.accounts.proposal.name = name;
}
if let Some(uri) = args.uri {
ctx.accounts.proposal.uri = uri;
}
if let Some(tags) = args.tags {
ctx.accounts.proposal.tags = tags;
}

Ok(())
}
7 changes: 7 additions & 0 deletions programs/proposal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ pub mod proposal {
) -> Result<()> {
update_proposal_config_v0::handler(ctx, args)
}

pub fn update_proposal_v0(
ctx: Context<UpdateProposalV0>,
args: UpdateProposalArgsV0,
) -> Result<()> {
update_proposal_v0::handler(ctx, args)
}
}

#[derive(Accounts)]
Expand Down
Loading