Skip to content

Commit

Permalink
revert migration changes based on feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
dancreee committed Aug 28, 2024
1 parent 74846a4 commit 6474186
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion contracts/rewards-collector/neutron/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mars-rewards-collector-neutron"
version = "2.0.2"
version = { workspace = true }
authors = { workspace = true }
edition = { workspace = true }
license = { workspace = true }
Expand Down
18 changes: 7 additions & 11 deletions contracts/rewards-collector/neutron/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ pub type NeutronCollector<'a> = Collector<'a, NeutronMsg, NeutronIbcMsgFactory>;

#[cfg(not(feature = "library"))]
pub mod entry {
use cosmwasm_std::{entry_point, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult};
use cosmwasm_std::{
entry_point, Binary, Deps, DepsMut, Empty, Env, MessageInfo, Response, StdResult,
};
use cw2::set_contract_version;
use mars_rewards_collector_base::{ContractError, ContractResult};
use mars_types::rewards_collector::{ExecuteMsg, InstantiateMsg, NeutronMigrateMsg, QueryMsg};
use mars_rewards_collector_base::ContractResult;
use mars_types::rewards_collector::{ExecuteMsg, InstantiateMsg, QueryMsg};
use neutron_sdk::bindings::msg::NeutronMsg;

use crate::{migrations, NeutronCollector};
Expand Down Expand Up @@ -90,13 +92,7 @@ pub mod entry {
}

#[entry_point]
pub fn migrate(
deps: DepsMut,
_env: Env,
msg: NeutronMigrateMsg,
) -> Result<Response, ContractError> {
match msg {
NeutronMigrateMsg::V1_2_0ToV2_0_2 {} => migrations::v2_0_2::migrate(deps),
}
pub fn migrate(deps: DepsMut, _env: Env, _msg: Empty) -> ContractResult<Response> {
migrations::v2_0_2::migrate(deps)
}
}
12 changes: 4 additions & 8 deletions contracts/rewards-collector/osmosis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub mod entry {
};
use cw2::set_contract_version;
use mars_rewards_collector_base::{contract::Collector, ContractError, ContractResult};
use mars_types::rewards_collector::{ExecuteMsg, InstantiateMsg, OsmosisMigrateMsg, QueryMsg};
use mars_types::rewards_collector::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};

use crate::migrations;

Expand Down Expand Up @@ -46,14 +46,10 @@ pub mod entry {
}

#[entry_point]
pub fn migrate(
deps: DepsMut,
_env: Env,
msg: OsmosisMigrateMsg,
) -> Result<Response, ContractError> {
pub fn migrate(deps: DepsMut, _env: Env, msg: MigrateMsg) -> Result<Response, ContractError> {
match msg {
OsmosisMigrateMsg::V1_0_0ToV2_0_0 {} => migrations::v2_0_0::migrate(deps),
OsmosisMigrateMsg::V2_0_0ToV2_0_1 {} => migrations::v2_0_1::migrate(deps),
MigrateMsg::V1_0_0ToV2_0_0 {} => migrations::v2_0_0::migrate(deps),
MigrateMsg::V2_0_0ToV2_0_1 {} => migrations::v2_0_1::migrate(deps),
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ use mars_rewards_collector_osmosis::{
migrations::v2_0_0::v1_state::{self, OwnerSetNoneProposed},
};
use mars_testing::mock_dependencies;
use mars_types::rewards_collector::OsmosisMigrateMsg;
use mars_types::rewards_collector::MigrateMsg;

#[test]
fn wrong_contract_name() {
let mut deps = mock_dependencies(&[]);
cw2::set_contract_version(deps.as_mut().storage, "contract_xyz", "1.0.0").unwrap();

let err = migrate(deps.as_mut(), mock_env(), OsmosisMigrateMsg::V1_0_0ToV2_0_0 {}).unwrap_err();
let err = migrate(deps.as_mut(), mock_env(), MigrateMsg::V1_0_0ToV2_0_0 {}).unwrap_err();

assert_eq!(
err,
Expand All @@ -34,7 +34,7 @@ fn wrong_contract_version() {
)
.unwrap();

let err = migrate(deps.as_mut(), mock_env(), OsmosisMigrateMsg::V1_0_0ToV2_0_0 {}).unwrap_err();
let err = migrate(deps.as_mut(), mock_env(), MigrateMsg::V1_0_0ToV2_0_0 {}).unwrap_err();

assert_eq!(
err,
Expand Down Expand Up @@ -78,7 +78,7 @@ fn successful_migration() {
};
v1_state::CONFIG.save(deps.as_mut().storage, &v1_config).unwrap();

let res = migrate(deps.as_mut(), mock_env(), OsmosisMigrateMsg::V1_0_0ToV2_0_0 {}).unwrap();
let res = migrate(deps.as_mut(), mock_env(), MigrateMsg::V1_0_0ToV2_0_0 {}).unwrap();

assert_eq!(res.messages, vec![]);
assert_eq!(res.events, vec![] as Vec<Event>);
Expand Down Expand Up @@ -123,7 +123,7 @@ fn successful_migration_to_v2_1_0() {
)
.unwrap();

let res = migrate(deps.as_mut(), mock_env(), OsmosisMigrateMsg::V2_0_0ToV2_0_1 {}).unwrap();
let res = migrate(deps.as_mut(), mock_env(), MigrateMsg::V2_0_0ToV2_0_1 {}).unwrap();

assert_eq!(res.messages, vec![]);
assert_eq!(res.events, vec![] as Vec<Event>);
Expand Down
7 changes: 1 addition & 6 deletions packages/types/src/rewards_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,7 @@ pub enum QueryMsg {
}

#[cw_serde]
pub enum OsmosisMigrateMsg {
pub enum MigrateMsg {
V1_0_0ToV2_0_0 {},
V2_0_0ToV2_0_1 {},
}

#[cw_serde]
pub enum NeutronMigrateMsg {
V1_2_0ToV2_0_2 {},
}

0 comments on commit 6474186

Please sign in to comment.