From fc5d737472f878fade5c473e3ebed4fc10d949f2 Mon Sep 17 00:00:00 2001 From: lubkoll <11710767+lubkoll@users.noreply.github.com> Date: Wed, 11 Sep 2024 11:33:17 +0200 Subject: [PATCH] Increase range-middleware version to v0.3.1 (#860) --- .../contracts/range-middleware/Cargo.toml | 9 ++--- .../schema/range-middleware.json | 27 ++++++++++++--- .../range-middleware/schema/raw/execute.json | 23 +++++++++++-- .../range-middleware/schema/raw/query.json | 2 -- .../range-middleware/src/contract.rs | 34 ++++--------------- .../contracts/range-middleware/src/error.rs | 4 +++ .../contracts/range-middleware/src/helpers.rs | 27 --------------- .../contracts/range-middleware/src/lib.rs | 1 - 8 files changed, 55 insertions(+), 72 deletions(-) delete mode 100644 smart-contracts/osmosis/contracts/range-middleware/src/helpers.rs diff --git a/smart-contracts/osmosis/contracts/range-middleware/Cargo.toml b/smart-contracts/osmosis/contracts/range-middleware/Cargo.toml index 9110e29fc..5c6b2ff43 100644 --- a/smart-contracts/osmosis/contracts/range-middleware/Cargo.toml +++ b/smart-contracts/osmosis/contracts/range-middleware/Cargo.toml @@ -2,7 +2,7 @@ authors = ["Nikita (rizz) "] edition = "2021" name = "range-middleware" -version = "0.3.0" +version = "0.3.1" [lib] crate-type = ["cdylib", "rlib"] @@ -11,9 +11,7 @@ crate-type = ["cdylib", "rlib"] name = "schema" [features] -# for more explicit tests, cargo test --features=backtraces backtraces = ["cosmwasm-std/backtraces"] -# use library feature to disable all instantiate/execute/query exports library = [] [dependencies] @@ -26,7 +24,4 @@ serde = { workspace = true } thiserror = { workspace = true } dex-router-osmosis = { workspace = true } cl-vault = {path = "../cl-vault", features = ["library"]} -osmosis-std = "0.25.0" - -[dev-dependencies] -cw-multi-test = { workspace = true } +osmosis-std = { workspace = true } diff --git a/smart-contracts/osmosis/contracts/range-middleware/schema/range-middleware.json b/smart-contracts/osmosis/contracts/range-middleware/schema/range-middleware.json index 0a4afa711..1156fc32c 100644 --- a/smart-contracts/osmosis/contracts/range-middleware/schema/range-middleware.json +++ b/smart-contracts/osmosis/contracts/range-middleware/schema/range-middleware.json @@ -1,6 +1,6 @@ { "contract_name": "range-middleware", - "contract_version": "0.3.0", + "contract_version": "0.3.1", "idl_version": "1.0.0", "instantiate": { "$schema": "http://json-schema.org/draft-07/schema#", @@ -25,7 +25,6 @@ "title": "ExecuteMsg", "oneOf": [ { - "description": "range operations", "type": "object", "required": [ "range_msg" @@ -38,7 +37,6 @@ "additionalProperties": false }, { - "description": "admin operations", "type": "object", "required": [ "admin_msg" @@ -200,6 +198,27 @@ } }, "additionalProperties": false + }, + { + "type": "object", + "required": [ + "remove_range" + ], + "properties": { + "remove_range": { + "type": "object", + "required": [ + "contract_address" + ], + "properties": { + "contract_address": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false } ] }, @@ -227,7 +246,6 @@ "title": "QueryMsg", "oneOf": [ { - "description": "range queries", "type": "object", "required": [ "range_query" @@ -240,7 +258,6 @@ "additionalProperties": false }, { - "description": "admin queries", "type": "object", "required": [ "admin_query" diff --git a/smart-contracts/osmosis/contracts/range-middleware/schema/raw/execute.json b/smart-contracts/osmosis/contracts/range-middleware/schema/raw/execute.json index cc0c8797d..72e1da708 100644 --- a/smart-contracts/osmosis/contracts/range-middleware/schema/raw/execute.json +++ b/smart-contracts/osmosis/contracts/range-middleware/schema/raw/execute.json @@ -3,7 +3,6 @@ "title": "ExecuteMsg", "oneOf": [ { - "description": "range operations", "type": "object", "required": [ "range_msg" @@ -16,7 +15,6 @@ "additionalProperties": false }, { - "description": "admin operations", "type": "object", "required": [ "admin_msg" @@ -178,6 +176,27 @@ } }, "additionalProperties": false + }, + { + "type": "object", + "required": [ + "remove_range" + ], + "properties": { + "remove_range": { + "type": "object", + "required": [ + "contract_address" + ], + "properties": { + "contract_address": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false } ] }, diff --git a/smart-contracts/osmosis/contracts/range-middleware/schema/raw/query.json b/smart-contracts/osmosis/contracts/range-middleware/schema/raw/query.json index f332ea56b..ecf1c1fac 100644 --- a/smart-contracts/osmosis/contracts/range-middleware/schema/raw/query.json +++ b/smart-contracts/osmosis/contracts/range-middleware/schema/raw/query.json @@ -3,7 +3,6 @@ "title": "QueryMsg", "oneOf": [ { - "description": "range queries", "type": "object", "required": [ "range_query" @@ -16,7 +15,6 @@ "additionalProperties": false }, { - "description": "admin queries", "type": "object", "required": [ "admin_query" diff --git a/smart-contracts/osmosis/contracts/range-middleware/src/contract.rs b/smart-contracts/osmosis/contracts/range-middleware/src/contract.rs index 11eb61c0d..0a994daa0 100644 --- a/smart-contracts/osmosis/contracts/range-middleware/src/contract.rs +++ b/smart-contracts/osmosis/contracts/range-middleware/src/contract.rs @@ -60,33 +60,11 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { #[cfg_attr(not(feature = "library"), entry_point)] pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result { - set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - - Ok(Response::new().add_attribute("migrate", "succesful")) -} - -#[cfg(test)] -mod tests { - use cosmwasm_std::testing::{mock_dependencies, mock_env}; - use cw2::{get_contract_version, ContractVersion}; + cw2::assert_contract_version(deps.storage, CONTRACT_NAME, "0.3.0")?; + let old_version = + cw2::ensure_from_older_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; - use super::*; - - #[test] - fn migrate_works() { - let mut deps = mock_dependencies(); - set_contract_version(deps.as_mut().storage, CONTRACT_NAME, "0.1.0").unwrap(); - - let env = mock_env(); - let msg = MigrateMsg {}; - - migrate(deps.as_mut(), env, msg).unwrap(); - assert_eq!( - get_contract_version(deps.as_ref().storage).unwrap(), - ContractVersion { - contract: CONTRACT_NAME.into(), - version: CONTRACT_VERSION.into() - } - ) - } + Ok(Response::new() + .add_attribute("old version", old_version.to_string()) + .add_attribute("new version", CONTRACT_VERSION)) } diff --git a/smart-contracts/osmosis/contracts/range-middleware/src/error.rs b/smart-contracts/osmosis/contracts/range-middleware/src/error.rs index a29d9f5ad..3baf93377 100644 --- a/smart-contracts/osmosis/contracts/range-middleware/src/error.rs +++ b/smart-contracts/osmosis/contracts/range-middleware/src/error.rs @@ -1,4 +1,5 @@ use cosmwasm_std::StdError; +use cw2::VersionError; use thiserror::Error; #[derive(Error, Debug, PartialEq)] @@ -6,6 +7,9 @@ pub enum ContractError { #[error("{0}")] Std(#[from] StdError), + #[error("{0}")] + Version(#[from] VersionError), + #[error("Unauthorized")] Unauthorized {}, diff --git a/smart-contracts/osmosis/contracts/range-middleware/src/helpers.rs b/smart-contracts/osmosis/contracts/range-middleware/src/helpers.rs deleted file mode 100644 index 6ffc885df..000000000 --- a/smart-contracts/osmosis/contracts/range-middleware/src/helpers.rs +++ /dev/null @@ -1,27 +0,0 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -use cosmwasm_std::{to_json_binary, Addr, CosmosMsg, StdResult, WasmMsg}; - -use crate::msg::ExecuteMsg; - -/// CwTemplateContract is a wrapper around Addr that provides a lot of helpers -/// for working with this. -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -pub struct CwTemplateContract(pub Addr); - -impl CwTemplateContract { - pub fn addr(&self) -> Addr { - self.0.clone() - } - - pub fn call>(&self, msg: T) -> StdResult { - let msg = to_json_binary(&msg.into())?; - Ok(WasmMsg::Execute { - contract_addr: self.addr().into(), - msg, - funds: vec![], - } - .into()) - } -} diff --git a/smart-contracts/osmosis/contracts/range-middleware/src/lib.rs b/smart-contracts/osmosis/contracts/range-middleware/src/lib.rs index 4c895c233..37b0a06ba 100644 --- a/smart-contracts/osmosis/contracts/range-middleware/src/lib.rs +++ b/smart-contracts/osmosis/contracts/range-middleware/src/lib.rs @@ -1,7 +1,6 @@ pub mod admin; pub mod contract; mod error; -pub mod helpers; pub mod msg; pub mod range; pub mod state;