Skip to content

Commit

Permalink
Add initial_dao_actions to dao_core
Browse files Browse the repository at this point in the history
  • Loading branch information
ismellike committed Dec 22, 2024
1 parent 547b0d0 commit ab1366f
Show file tree
Hide file tree
Showing 19 changed files with 59 additions and 4 deletions.
1 change: 1 addition & 0 deletions ci/bootstrap-env/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ fn main() -> Result<()> {
label: "DAO DAO Proposal Module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

// Init dao dao dao with an initial treasury of 9000000 tokens
Expand Down
1 change: 1 addition & 0 deletions ci/integration-tests/src/helpers/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ pub fn create_dao(
label: "DAO DAO Proposal Module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

chain
Expand Down
9 changes: 7 additions & 2 deletions contracts/dao-dao-core/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,16 @@ pub fn instantiate(
TOTAL_PROPOSAL_MODULE_COUNT.save(deps.storage, &0)?;
ACTIVE_PROPOSAL_MODULE_COUNT.save(deps.storage, &0)?;

Ok(Response::new()
let res = Response::new()
.add_attribute("action", "instantiate")
.add_attribute("sender", info.sender)
.add_submessage(vote_module_msg)
.add_submessages(proposal_module_msgs))
.add_submessages(proposal_module_msgs);

if let Some(initial_dao_actions) = msg.initial_dao_actions {
return Ok(res.add_messages(initial_dao_actions));
}
Ok(res)
}

#[cfg_attr(not(feature = "library"), entry_point)]
Expand Down
13 changes: 13 additions & 0 deletions contracts/dao-dao-core/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ fn test_instantiate_with_n_gov_modules(n: usize) {
})
.collect(),
initial_items: None,
initial_dao_actions: None,
};
let gov_addr = instantiate_gov(&mut app, gov_id, instantiate);

Expand Down Expand Up @@ -180,6 +181,7 @@ makes wickedness."
},
proposal_modules_instantiate_info: governance_modules,
initial_items: None,
initial_dao_actions: None,
};
instantiate_gov(&mut app, gov_id, instantiate);
}
Expand Down Expand Up @@ -217,6 +219,7 @@ fn test_update_config() {
label: "voting module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

let gov_addr = app
Expand Down Expand Up @@ -316,6 +319,7 @@ fn test_swap_governance(swaps: Vec<(u32, u32)>) {
label: "governance module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

let gov_addr = app
Expand Down Expand Up @@ -495,6 +499,7 @@ fn test_removed_modules_can_not_execute() {
label: "governance module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

let gov_addr = app
Expand Down Expand Up @@ -658,6 +663,7 @@ fn test_module_already_disabled() {
label: "governance module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

let gov_addr = app
Expand Down Expand Up @@ -760,6 +766,7 @@ fn test_swap_voting_module() {
label: "governance module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

let gov_addr = app
Expand Down Expand Up @@ -866,6 +873,7 @@ fn test_permissions() {
initial_items: None,
automatically_add_cw20s: true,
automatically_add_cw721s: true,
initial_dao_actions: None,
};

let gov_addr = app
Expand Down Expand Up @@ -966,6 +974,7 @@ fn do_standard_instantiate(auto_add: bool, admin: Option<String>) -> (Addr, App)
label: "governance module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

let gov_addr = app
Expand Down Expand Up @@ -1683,6 +1692,7 @@ fn test_list_items() {
label: "governance module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

let gov_addr = app
Expand Down Expand Up @@ -1817,6 +1827,7 @@ fn test_instantiate_with_items() {
label: "governance module".to_string(),
}],
initial_items: Some(initial_items.clone()),
initial_dao_actions: None,
};

// Ensure duplicates are dissallowed.
Expand Down Expand Up @@ -2646,6 +2657,7 @@ fn test_migrate_from_compatible() {
label: "governance module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

let core_addr = app
Expand Down Expand Up @@ -2947,6 +2959,7 @@ fn test_module_prefixes() {
},
],
initial_items: None,
initial_dao_actions: None,
};

let gov_addr = app
Expand Down
4 changes: 4 additions & 0 deletions contracts/external/btsg-ft-factory/src/testing/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ fn test_issue_fantoken() -> anyhow::Result<()> {
label: "DAO DAO governance module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

let dao = app
Expand Down Expand Up @@ -192,6 +193,7 @@ fn test_initial_fantoken_balances() -> anyhow::Result<()> {
label: "DAO DAO governance module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

let dao = app
Expand Down Expand Up @@ -299,6 +301,7 @@ fn test_fantoken_minter_and_authority_set_to_dao() -> anyhow::Result<()> {
label: "DAO DAO governance module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

let dao = app
Expand Down Expand Up @@ -456,6 +459,7 @@ fn test_fantoken_can_be_staked() -> anyhow::Result<()> {
label: "DAO DAO governance module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

let dao = app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ fn test_set_self_admin_instantiate2() {
label: "DAO DAO Proposal Module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

let salt = Binary::from("salt".as_bytes());
Expand Down
2 changes: 2 additions & 0 deletions contracts/external/cw-admin-factory/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ pub fn test_set_self_admin() {
},
],
initial_items: None,
initial_dao_actions: None,
};

let res: AppResponse = app
Expand Down Expand Up @@ -174,6 +175,7 @@ pub fn test_authorized_set_self_admin() {
},
],
initial_items: None,
initial_dao_actions: None,
};

// Fails when not the admin.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ impl SuiteBuilder {
label: "condorcet module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
dao_uri: None,
};
let core = app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ pub fn _instantiate_with_staked_cw721_governance(
label: "DAO DAO governance module.".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
dao_uri: None,
};

Expand Down Expand Up @@ -297,6 +298,7 @@ pub fn instantiate_with_native_staked_balances_governance(
label: "DAO DAO governance module.".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
dao_uri: None,
};

Expand Down Expand Up @@ -414,6 +416,7 @@ pub fn instantiate_with_cw20_balances_governance(
label: "DAO DAO governance module.".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
dao_uri: None,
};

Expand Down Expand Up @@ -500,6 +503,7 @@ pub fn instantiate_with_staked_balances_governance(
label: "DAO DAO governance module.".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
dao_uri: None,
};

Expand Down Expand Up @@ -639,6 +643,7 @@ pub fn instantiate_with_multiple_staked_balances_governance(
label: "DAO DAO governance module.".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
dao_uri: None,
};

Expand Down Expand Up @@ -754,6 +759,7 @@ pub fn instantiate_with_staking_active_threshold(
label: "DAO DAO governance module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
dao_uri: None,
};

Expand Down Expand Up @@ -833,6 +839,7 @@ pub fn _instantiate_with_cw4_groups_governance(
label: "DAO DAO governance module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
dao_uri: None,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ pub(crate) fn instantiate_with_staked_cw721_governance(
label: "DAO DAO governance module.".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

let core_addr = app
Expand Down Expand Up @@ -298,6 +299,7 @@ pub(crate) fn instantiate_with_native_staked_balances_governance(
label: "DAO DAO governance module.".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

let core_addr = app
Expand Down Expand Up @@ -419,6 +421,7 @@ pub(crate) fn instantiate_with_staked_balances_governance(
label: "DAO DAO governance module.".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

let core_addr = app
Expand Down Expand Up @@ -534,6 +537,7 @@ pub(crate) fn instantiate_with_staking_active_threshold(
label: "DAO DAO governance module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

app.instantiate_contract(
Expand Down Expand Up @@ -613,6 +617,7 @@ pub(crate) fn instantiate_with_cw4_groups_governance(
label: "DAO DAO governance module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

let addr = app
Expand Down
1 change: 1 addition & 0 deletions contracts/test/dao-proposal-hook-counter/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ fn instantiate_with_default_governance(
label: "DAO DAO governance module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

instantiate_governance(app, governance_id, governance_instantiate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ fn test_full_integration_with_factory() {
label: "DAO DAO Proposal Module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

// Instantiating without funds fails
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ impl TestEnvBuilder {
label: "DAO DAO Proposal Module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

// Instantiate DAO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ fn test_factory() {
label: "DAO DAO Proposal Module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

// Instantiate DAO succeeds
Expand Down Expand Up @@ -514,6 +515,7 @@ fn test_factory_funds_pass_through() {
label: "DAO DAO Proposal Module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

// Instantiate DAO fails because no funds to create the token were sent
Expand Down Expand Up @@ -640,6 +642,7 @@ fn test_factory_no_callback() {
label: "DAO DAO Proposal Module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

// Instantiate DAO fails because no callback
Expand Down Expand Up @@ -721,6 +724,7 @@ fn test_factory_wrong_callback() {
label: "DAO DAO Proposal Module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

// Instantiate DAO fails because of wrong callback
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ impl TestEnvBuilder {
label: "DAO DAO Proposal Module".to_string(),
}],
initial_items: None,
initial_dao_actions: None,
};

// Instantiate DAO
Expand Down
4 changes: 2 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ workspace-optimize:
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
--platform linux/arm64 \
cosmwasm/optimizer-arm64:0.16.0; \
cosmwasm/optimizer-arm64:0.16.1; \
elif [[ $(uname -m) == 'x86_64' ]]; then docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
--platform linux/amd64 \
cosmwasm/optimizer:0.16.0; fi
cosmwasm/optimizer:0.16.1; fi
2 changes: 2 additions & 0 deletions packages/dao-interface/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ pub struct InstantiateMsg {
pub initial_items: Option<Vec<InitialItem>>,
/// Implements the DAO Star standard: <https://daostar.one/EIP>
pub dao_uri: Option<String>,
/// Optional initial actions for the DAO
pub initial_dao_actions: Option<Vec<CosmosMsg>>,
}

#[cw_serde]
Expand Down
Loading

0 comments on commit ab1366f

Please sign in to comment.