diff --git a/framework/contracts/account/src/error.rs b/framework/contracts/account/src/error.rs index 95e3808ac..08a4a41e8 100644 --- a/framework/contracts/account/src/error.rs +++ b/framework/contracts/account/src/error.rs @@ -42,6 +42,9 @@ pub enum AccountError { #[error("The provided module {0} can't be installed on an Abstract account")] ModuleNotInstallable(String), + #[error("The module {0} needs an init msg to be installed but not was provided")] + InitMsgMissing(String), + #[error("The name of the proposed module can not have length 0.")] InvalidModuleName {}, diff --git a/framework/contracts/account/src/modules.rs b/framework/contracts/account/src/modules.rs index a24dad700..8ef653539 100644 --- a/framework/contracts/account/src/modules.rs +++ b/framework/contracts/account/src/modules.rs @@ -130,7 +130,7 @@ pub fn _install_modules( add_to_account.push((module.info.id(), module_address.clone())); install_context.push((module.clone(), Some(module_address))); - Some(init_msg.unwrap()) + Some(init_msg.ok_or(AccountError::InitMsgMissing(module.info.id()))?) } _ => return Err(AccountError::ModuleNotInstallable(module.info.to_string())), }; diff --git a/framework/contracts/account/tests/apps.rs b/framework/contracts/account/tests/apps.rs index 5ee578f36..48e36c879 100644 --- a/framework/contracts/account/tests/apps.rs +++ b/framework/contracts/account/tests/apps.rs @@ -14,7 +14,7 @@ use abstract_std::{ registry::ModuleFilter, }; use abstract_testing::prelude::*; -use cosmwasm_std::{coin, CosmosMsg}; +use cosmwasm_std::{coin, CosmosMsg, StdError}; use cw_controllers::{AdminError, AdminResponse}; use cw_orch::prelude::*; @@ -81,6 +81,24 @@ fn account_install_app() -> AResult { Ok(()) } +#[test] +fn account_install_app_without_init_msg() -> AResult { + let chain = MockBech32::new("mock"); + let deployment = Abstract::deploy_on(chain.clone(), ())?; + let account = crate::create_default_account(&chain.sender_addr(), &deployment)?; + + deployment + .registry + .claim_namespace(account.id()?, "tester".to_owned())?; + + let app = MockApp::new_test(chain.clone()); + MockApp::deploy(&app, APP_VERSION.parse().unwrap(), DeployStrategy::Try)?; + account + .install_module::(APP_ID, None, &[]) + .unwrap_err(); + Ok(()) +} + #[test] fn account_app_ownership() -> AResult { let chain = MockBech32::new("mock"); diff --git a/framework/packages/abstract-testing/src/lib.rs b/framework/packages/abstract-testing/src/lib.rs index 2cba69b24..0654f91cd 100644 --- a/framework/packages/abstract-testing/src/lib.rs +++ b/framework/packages/abstract-testing/src/lib.rs @@ -75,6 +75,16 @@ pub fn abstract_mock_querier_builder(mock_api: MockApi) -> MockQuerierBuilder { ModuleReference::Account(1), ), ) + .with_contract_map_entry( + // Adding a map module inside the registry + &abstr.registry, + REGISTERED_MODULES, + ( + &ModuleInfo::from_id(TEST_MODULE_ID, ModuleVersion::Version(TEST_VERSION.into())) + .unwrap(), + ModuleReference::App(2), + ), + ) .with_contract_item(abstr.account.addr(), ACCOUNT_ID, &ABSTRACT_ACCOUNT_ID) .with_contract_version(abstr.account.addr(), ACCOUNT, TEST_VERSION) .with_smart_handler(&abstr.module_address, |msg| {