From 89fe3e6f84b7d0b7696f12a233ac0ced758b127a Mon Sep 17 00:00:00 2001 From: larry <26318510+larry0x@users.noreply.github.com> Date: Thu, 31 Aug 2023 17:28:12 +0100 Subject: [PATCH 1/4] fix migrate from version --- contracts/vesting/src/migrations/v1_3_0.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/vesting/src/migrations/v1_3_0.rs b/contracts/vesting/src/migrations/v1_3_0.rs index 4178691..39bb68b 100644 --- a/contracts/vesting/src/migrations/v1_3_0.rs +++ b/contracts/vesting/src/migrations/v1_3_0.rs @@ -8,7 +8,7 @@ use crate::{ state::CONFIG, }; -const FROM_VERSION: &str = "1.2.0"; +const FROM_VERSION: &str = "1.0.0"; pub mod v1_2_0_state { use cosmwasm_std::Addr; From 58414bdfad95deddcf3f2bd7866e32acf362cb95 Mon Sep 17 00:00:00 2001 From: larry <26318510+larry0x@users.noreply.github.com> Date: Thu, 31 Aug 2023 17:31:10 +0100 Subject: [PATCH 2/4] individual versioning for each contract --- Cargo.lock | 4 ++-- Cargo.toml | 1 - contracts/delegator/Cargo.toml | 2 +- contracts/vesting/Cargo.toml | 2 +- contracts/vesting/src/contract.rs | 4 ++-- contracts/vesting/src/migrations/mod.rs | 2 +- contracts/vesting/src/migrations/{v1_3_0.rs => v1_1_0.rs} | 8 ++++---- contracts/vesting/tests/tests.rs | 8 ++++---- 8 files changed, 15 insertions(+), 16 deletions(-) rename contracts/vesting/src/migrations/{v1_3_0.rs => v1_1_0.rs} (85%) diff --git a/Cargo.lock b/Cargo.lock index 65a1ad5..9bb8409 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -415,7 +415,7 @@ checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "mars-delegator" -version = "1.3.0" +version = "1.2.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", @@ -426,7 +426,7 @@ dependencies = [ [[package]] name = "mars-vesting" -version = "1.3.0" +version = "1.1.0" dependencies = [ "cosmwasm-schema", "cosmwasm-std", diff --git a/Cargo.toml b/Cargo.toml index e6d443b..e53f188 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,6 @@ members = ["contracts/*"] [workspace.package] -version = "1.3.0" authors = ["Larry Engineer "] edition = "2021" rust-version = "1.69" diff --git a/contracts/delegator/Cargo.toml b/contracts/delegator/Cargo.toml index 0cd0275..a703cd8 100644 --- a/contracts/delegator/Cargo.toml +++ b/contracts/delegator/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "mars-delegator" description = "Smart contract managing community fund delegation to genesis validators on Mars Hub" -version = { workspace = true } +version = "1.2.0" authors = { workspace = true } edition = { workspace = true } rust-version = { workspace = true } diff --git a/contracts/vesting/Cargo.toml b/contracts/vesting/Cargo.toml index d014886..87a91dd 100644 --- a/contracts/vesting/Cargo.toml +++ b/contracts/vesting/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "mars-vesting" description = "Smart contract managing token vesting for Mars protocol contributors" -version = { workspace = true } +version = "1.1.0" authors = { workspace = true } edition = { workspace = true } rust-version = { workspace = true } diff --git a/contracts/vesting/src/contract.rs b/contracts/vesting/src/contract.rs index b0956e8..56f5681 100644 --- a/contracts/vesting/src/contract.rs +++ b/contracts/vesting/src/contract.rs @@ -11,7 +11,7 @@ use cw_utils::must_pay; use crate::{ error::{Error, Result}, helpers::{compute_position_response, compute_withdrawable}, - migrations::v1_3_0, + migrations::v1_1_0, msg::{ Config, ExecuteMsg, Position, PositionResponse, QueryMsg, Schedule, VotingPowerResponse, }, @@ -307,5 +307,5 @@ pub fn query_positions( #[cfg_attr(not(feature = "library"), entry_point)] pub fn migrate(deps: DepsMut, _: Env, _: Empty) -> Result { - v1_3_0::migrate(deps) + v1_1_0::migrate(deps) } diff --git a/contracts/vesting/src/migrations/mod.rs b/contracts/vesting/src/migrations/mod.rs index bd6dc60..ff86322 100644 --- a/contracts/vesting/src/migrations/mod.rs +++ b/contracts/vesting/src/migrations/mod.rs @@ -1 +1 @@ -pub mod v1_3_0; +pub mod v1_1_0; diff --git a/contracts/vesting/src/migrations/v1_3_0.rs b/contracts/vesting/src/migrations/v1_1_0.rs similarity index 85% rename from contracts/vesting/src/migrations/v1_3_0.rs rename to contracts/vesting/src/migrations/v1_1_0.rs index 39bb68b..23a9dce 100644 --- a/contracts/vesting/src/migrations/v1_3_0.rs +++ b/contracts/vesting/src/migrations/v1_1_0.rs @@ -10,7 +10,7 @@ use crate::{ const FROM_VERSION: &str = "1.0.0"; -pub mod v1_2_0_state { +pub mod v1_0_0_state { use cosmwasm_std::Addr; use cw_storage_plus::Item; @@ -27,9 +27,9 @@ pub fn migrate(deps: DepsMut) -> Result { // CONFIG updated, re-initializing let cfg = Config { - owner: v1_2_0_state::OWNER.load(deps.storage)?, - denom: v1_2_0_state::VEST_DENOM.into(), - unlock_schedule: v1_2_0_state::UNLOCK_SCHEDULE.load(deps.storage)?, + owner: v1_0_0_state::OWNER.load(deps.storage)?, + denom: v1_0_0_state::VEST_DENOM.into(), + unlock_schedule: v1_0_0_state::UNLOCK_SCHEDULE.load(deps.storage)?, }; CONFIG.save(deps.storage, &cfg)?; diff --git a/contracts/vesting/tests/tests.rs b/contracts/vesting/tests/tests.rs index a7a129a..ef30b33 100644 --- a/contracts/vesting/tests/tests.rs +++ b/contracts/vesting/tests/tests.rs @@ -8,7 +8,7 @@ use cw_utils::PaymentError; use mars_vesting::{ contract::{execute, instantiate, migrate, query}, error::Error, - migrations::v1_3_0::v1_2_0_state, + migrations::v1_1_0::v1_0_0_state, msg::{ Config, ExecuteMsg, Position, PositionResponse, QueryMsg, Schedule, VotingPowerResponse, }, @@ -618,14 +618,14 @@ fn proper_migration() { cw2::set_contract_version(deps.as_mut().storage, "crates.io:mars-vesting", "1.2.0").unwrap(); let old_owner = "spiderman_246"; - v1_2_0_state::OWNER.save(deps.as_mut().storage, &Addr::unchecked(old_owner)).unwrap(); + v1_0_0_state::OWNER.save(deps.as_mut().storage, &Addr::unchecked(old_owner)).unwrap(); let old_schedule = Schedule { start_time: 1614600000, cliff: 31536000, duration: 126144000, }; - v1_2_0_state::UNLOCK_SCHEDULE.save(deps.as_mut().storage, &old_schedule).unwrap(); + v1_0_0_state::UNLOCK_SCHEDULE.save(deps.as_mut().storage, &old_schedule).unwrap(); let res = migrate(deps.as_mut(), mock_env(), Empty {}).unwrap(); @@ -637,7 +637,7 @@ fn proper_migration() { ); let config = CONFIG.load(deps.as_ref().storage).unwrap(); - assert_eq!(config.denom, v1_2_0_state::VEST_DENOM.to_string()); + assert_eq!(config.denom, v1_0_0_state::VEST_DENOM.to_string()); assert_eq!(config.owner.to_string(), old_owner.to_string()); assert_eq!(config.unlock_schedule, old_schedule); } From 3ffbc20e5ddfb8adfc012da68c3f0f0d4ae00422 Mon Sep 17 00:00:00 2001 From: larry <26318510+larry0x@users.noreply.github.com> Date: Thu, 31 Aug 2023 17:33:42 +0100 Subject: [PATCH 3/4] fix tests --- contracts/vesting/tests/tests.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contracts/vesting/tests/tests.rs b/contracts/vesting/tests/tests.rs index ef30b33..046b85b 100644 --- a/contracts/vesting/tests/tests.rs +++ b/contracts/vesting/tests/tests.rs @@ -592,7 +592,7 @@ fn invalid_contract_version() { let old_contract_version = ContractVersion { contract: "crates.io:mars-vesting".to_string(), - version: "1.0.0".to_string(), + version: "0.9.0".to_string(), }; set_contract_version( @@ -605,8 +605,8 @@ fn invalid_contract_version() { let err = migrate(deps.as_mut(), env, Empty {}).unwrap_err(); assert_eq!( Error::Version(VersionError::WrongVersion { - expected: "1.2.0".to_string(), - found: "1.0.0".to_string() + expected: "1.0.0".to_string(), + found: "0.9.0".to_string() }), err ); @@ -615,7 +615,7 @@ fn invalid_contract_version() { #[test] fn proper_migration() { let mut deps = mock_dependencies(); - cw2::set_contract_version(deps.as_mut().storage, "crates.io:mars-vesting", "1.2.0").unwrap(); + cw2::set_contract_version(deps.as_mut().storage, "crates.io:mars-vesting", "1.0.0").unwrap(); let old_owner = "spiderman_246"; v1_0_0_state::OWNER.save(deps.as_mut().storage, &Addr::unchecked(old_owner)).unwrap(); @@ -633,7 +633,7 @@ fn proper_migration() { assert!(res.data.is_none()); assert_eq!( res.attributes, - vec![attr("action", "migrate"), attr("from_version", "1.2.0"), attr("to_version", "1.3.0"),] + vec![attr("action", "migrate"), attr("from_version", "1.0.0"), attr("to_version", "1.1.0"),] ); let config = CONFIG.load(deps.as_ref().storage).unwrap(); From 9990ca0ceb5642dba1377fecac8f02e1b8496d52 Mon Sep 17 00:00:00 2001 From: larry <26318510+larry0x@users.noreply.github.com> Date: Thu, 31 Aug 2023 17:37:40 +0100 Subject: [PATCH 4/4] updata schema and typescript types --- schemas/mars-delegator/mars-delegator.json | 2 +- schemas/mars-vesting/mars-vesting.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/schemas/mars-delegator/mars-delegator.json b/schemas/mars-delegator/mars-delegator.json index 9fe4217..ecb221c 100644 --- a/schemas/mars-delegator/mars-delegator.json +++ b/schemas/mars-delegator/mars-delegator.json @@ -1,6 +1,6 @@ { "contract_name": "mars-delegator", - "contract_version": "1.3.0", + "contract_version": "1.2.0", "idl_version": "1.0.0", "instantiate": { "$schema": "http://json-schema.org/draft-07/schema#", diff --git a/schemas/mars-vesting/mars-vesting.json b/schemas/mars-vesting/mars-vesting.json index 8da6bc9..b05c79b 100644 --- a/schemas/mars-vesting/mars-vesting.json +++ b/schemas/mars-vesting/mars-vesting.json @@ -1,6 +1,6 @@ { "contract_name": "mars-vesting", - "contract_version": "1.3.0", + "contract_version": "1.1.0", "idl_version": "1.0.0", "instantiate": { "$schema": "http://json-schema.org/draft-07/schema#",