Skip to content

Commit

Permalink
feat: added title field #NTRN-174
Browse files Browse the repository at this point in the history
  • Loading branch information
joldie777 committed Apr 1, 2024
1 parent 0f66a7a commit 8636905
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
2 changes: 2 additions & 0 deletions contracts/dao/proposal/cwd-proposal-multiple/src/proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,12 @@ mod tests {
// The last option that gets added in into_checked is always the none of the above option
let options = vec![
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 1".to_string(),
msgs: None,
},
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 2".to_string(),
msgs: None,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,12 @@ where

let options = vec![
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 1".to_string(),
msgs: None,
},
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 2".to_string(),
msgs: None,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,13 @@ fn test_propose() {

let options = vec![
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 1".to_string(),
msgs: None,
},
MultipleChoiceOption {
description: "multiple choice option 1".to_string(),
title: "title".to_string(),
description: "multiple choice option 2".to_string(),
msgs: None,
},
];
Expand Down Expand Up @@ -243,6 +245,7 @@ fn test_propose_wrong_num_choices() {

let options = vec![
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 1".to_string(),
msgs: None,
};
Expand Down Expand Up @@ -343,10 +346,12 @@ fn test_no_early_pass_with_min_duration() {

let options = vec![
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 1".to_string(),
msgs: None,
},
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 2".to_string(),
msgs: None,
},
Expand Down Expand Up @@ -452,10 +457,12 @@ fn test_propose_with_messages() {

let options = vec![
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 1".to_string(),
msgs: Some(vec![CosmosMsg::Wasm(wasm_msg)]),
},
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 2".to_string(),
msgs: None,
},
Expand Down Expand Up @@ -613,10 +620,12 @@ fn test_min_duration_same_as_proposal_duration() {

let options = vec![
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 1".to_string(),
msgs: None,
},
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 2".to_string(),
msgs: None,
},
Expand Down Expand Up @@ -786,10 +795,12 @@ fn test_native_proposal_deposit() {
let mc_options = MultipleChoiceOptions {
options: vec![
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 1".to_string(),
msgs: None,
},
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 2".to_string(),
msgs: None,
},
Expand Down Expand Up @@ -919,10 +930,12 @@ fn test_cant_propose_zero_power() {

let options = vec![
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 1".to_string(),
msgs: None,
},
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 2".to_string(),
msgs: None,
},
Expand Down Expand Up @@ -1016,10 +1029,12 @@ fn test_open_proposal_submission() {
MultipleChoiceOptions {
options: vec![
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 1".to_string(),
msgs: None,
},
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 2".to_string(),
msgs: None,
},
Expand All @@ -1044,20 +1059,23 @@ fn test_open_proposal_submission() {
},
choices: vec![
CheckedMultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 1".to_string(),
msgs: None,
option_type: MultipleChoiceOptionType::Standard,
vote_count: Uint128::zero(),
index: 0,
},
CheckedMultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 2".to_string(),
msgs: None,
option_type: MultipleChoiceOptionType::Standard,
vote_count: Uint128::zero(),
index: 1,
},
CheckedMultipleChoiceOption {
title: "title".to_string(),
description: "None of the above".to_string(),
msgs: None,
option_type: MultipleChoiceOptionType::None,
Expand Down Expand Up @@ -1117,10 +1135,12 @@ fn test_execute_expired_proposal() {

let options = vec![
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 1".to_string(),
msgs: None,
},
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 2".to_string(),
msgs: None,
},
Expand Down Expand Up @@ -1236,10 +1256,12 @@ fn test_query_list_proposals() {

let options = vec![
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 1".to_string(),
msgs: None,
},
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 2".to_string(),
msgs: None,
},
Expand Down Expand Up @@ -1485,10 +1507,12 @@ fn test_revoting() {

let options = vec![
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 1".to_string(),
msgs: None,
},
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 2".to_string(),
msgs: None,
},
Expand Down Expand Up @@ -1612,10 +1636,12 @@ fn test_allow_revoting_config_changes() {

let options = vec![
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 1".to_string(),
msgs: None,
},
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 2".to_string(),
msgs: None,
},
Expand Down Expand Up @@ -1757,10 +1783,12 @@ fn test_revoting_same_vote_twice() {

let options = vec![
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 1".to_string(),
msgs: None,
},
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 2".to_string(),
msgs: None,
},
Expand Down Expand Up @@ -1847,10 +1875,12 @@ fn test_invalid_revote_does_not_invalidate_initial_vote() {

let options = vec![
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 1".to_string(),
msgs: None,
},
MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 2".to_string(),
msgs: None,
},
Expand Down Expand Up @@ -1967,6 +1997,7 @@ fn test_close_failed_proposal() {

let options = vec![
MultipleChoiceOption {
title: "title".to_string(),
description: "Burn or burn".to_string(),
msgs: Some(vec![WasmMsg::Execute {
contract_addr: "token_contract".to_string(),
Expand All @@ -1976,6 +2007,7 @@ fn test_close_failed_proposal() {
.into()]),
},
MultipleChoiceOption {
title: "title".to_string(),
description: "Don't burn".to_string(),
msgs: None,
},
Expand Down Expand Up @@ -2039,6 +2071,7 @@ fn test_close_failed_proposal() {
choices: MultipleChoiceOptions {
options: vec![
MultipleChoiceOption {
title: "title".to_string(),
description: "Disable closing failed proposals".to_string(),
msgs: Some(vec![WasmMsg::Execute {
contract_addr: govmod.to_string(),
Expand All @@ -2057,6 +2090,7 @@ fn test_close_failed_proposal() {
.into()]),
},
MultipleChoiceOption {
title: "title".to_string(),
description: "Don't disable".to_string(),
msgs: None,
},
Expand Down
7 changes: 7 additions & 0 deletions packages/cwd-voting/src/multiple_choice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ pub struct MultipleChoiceOptions {
/// Unchecked multiple choice option
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
pub struct MultipleChoiceOption {
pub title: String,
pub description: String,
pub msgs: Option<Vec<CosmosMsg<NeutronMsg>>>,
}
Expand All @@ -118,6 +119,7 @@ pub struct CheckedMultipleChoiceOption {
// Workaround due to not being able to use HashMaps in Cosmwasm.
pub index: u32,
pub option_type: MultipleChoiceOptionType,
pub title: String,
pub description: String,
pub msgs: Option<Vec<CosmosMsg<NeutronMsg>>>,
pub vote_count: Uint128,
Expand All @@ -142,6 +144,7 @@ impl MultipleChoiceOptions {
let checked_option = CheckedMultipleChoiceOption {
index: idx as u32,
option_type: MultipleChoiceOptionType::Standard,
title: choice.title,
description: choice.description,
msgs: choice.msgs,
vote_count: Uint128::zero(),
Expand All @@ -153,6 +156,7 @@ impl MultipleChoiceOptions {
let none_option = CheckedMultipleChoiceOption {
index: (checked_options.capacity() - 1) as u32,
option_type: MultipleChoiceOptionType::None,
title: NONE_OPTION_DESCRIPTION.to_string(),
description: NONE_OPTION_DESCRIPTION.to_string(),
msgs: None,
vote_count: Uint128::zero(),
Expand Down Expand Up @@ -205,10 +209,12 @@ mod test {
fn test_into_checked() {
let options = vec![
super::MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 1".to_string(),
msgs: None,
},
super::MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 2".to_string(),
msgs: None,
},
Expand Down Expand Up @@ -248,6 +254,7 @@ mod test {
#[test]
fn test_into_checked_wrong_num_choices() {
let options = vec![super::MultipleChoiceOption {
title: "title".to_string(),
description: "multiple choice option 1".to_string(),
msgs: None,
}];
Expand Down

0 comments on commit 8636905

Please sign in to comment.