diff --git a/contracts/admin/src/lib.rs b/contracts/admin/src/lib.rs index 7e844e11b..6ff612e68 100644 --- a/contracts/admin/src/lib.rs +++ b/contracts/admin/src/lib.rs @@ -3,13 +3,14 @@ use platform::response; use sdk::cosmwasm_std::entry_point; use sdk::{ cosmwasm_ext::Response, - cosmwasm_std::{ensure_eq, DepsMut, Env, MessageInfo, Reply, StdResult}, + cosmwasm_std::{ensure_eq, DepsMut, Env, MessageInfo, Reply}, }; use versioning::{version, VersionSegment}; use self::{ error::ContractError, msg::{InstantiateMsg, MigrateMsg, SudoMsg}, + result::ContractResult, state::{contracts as state_contracts, migration_release}, }; @@ -17,6 +18,7 @@ pub mod common; pub mod error; pub mod migrate_contracts; pub mod msg; +pub mod result; pub mod state; // version info for migration info @@ -29,7 +31,7 @@ pub fn instantiate( _env: Env, _info: MessageInfo, msg: InstantiateMsg, -) -> Result { +) -> ContractResult { versioning::initialize(deps.storage, version!(CONTRACT_STORAGE_VERSION))?; msg.validate(&deps.querier)?; @@ -40,14 +42,16 @@ pub fn instantiate( } #[cfg_attr(feature = "contract-with-bindings", entry_point)] -pub fn migrate(deps: DepsMut<'_>, _env: Env, _msg: MigrateMsg) -> StdResult { +pub fn migrate(deps: DepsMut<'_>, _env: Env, _msg: MigrateMsg) -> ContractResult { versioning::update_software(deps.storage, version!(CONTRACT_STORAGE_VERSION))?; - response::response(versioning::release()).map(Into::into) + response::response(versioning::release()) + .map(Into::into) + .map_err(Into::into) } #[cfg_attr(feature = "contract-with-bindings", entry_point)] -pub fn sudo(deps: DepsMut<'_>, env: Env, msg: SudoMsg) -> Result { +pub fn sudo(deps: DepsMut<'_>, env: Env, msg: SudoMsg) -> ContractResult { match msg { SudoMsg::MigrateContracts(migrate_contracts) => { migrate_contracts::migrate(deps.storage, env.contract.address, migrate_contracts) @@ -56,7 +60,7 @@ pub fn sudo(deps: DepsMut<'_>, env: Env, msg: SudoMsg) -> Result, _env: Env, msg: Reply) -> Result { +pub fn reply(deps: DepsMut<'_>, _env: Env, msg: Reply) -> ContractResult { let expected_release: String = migration_release::load(deps.storage)?; let reported_release: String = diff --git a/contracts/admin/src/result.rs b/contracts/admin/src/result.rs new file mode 100644 index 000000000..eaac4833b --- /dev/null +++ b/contracts/admin/src/result.rs @@ -0,0 +1,3 @@ +use crate::error::ContractError; + +pub type ContractResult = Result;