Skip to content

Commit

Permalink
Increase range-middleware version to v0.3.1 (#860)
Browse files Browse the repository at this point in the history
  • Loading branch information
lubkoll authored Sep 11, 2024
1 parent 3cb0520 commit fc5d737
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 72 deletions.
9 changes: 2 additions & 7 deletions smart-contracts/osmosis/contracts/range-middleware/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
authors = ["Nikita (rizz) <[email protected]>"]
edition = "2021"
name = "range-middleware"
version = "0.3.0"
version = "0.3.1"

[lib]
crate-type = ["cdylib", "rlib"]
Expand All @@ -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]
Expand All @@ -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 }
Original file line number Diff line number Diff line change
@@ -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#",
Expand All @@ -25,7 +25,6 @@
"title": "ExecuteMsg",
"oneOf": [
{
"description": "range operations",
"type": "object",
"required": [
"range_msg"
Expand All @@ -38,7 +37,6 @@
"additionalProperties": false
},
{
"description": "admin operations",
"type": "object",
"required": [
"admin_msg"
Expand Down Expand Up @@ -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
}
]
},
Expand Down Expand Up @@ -227,7 +246,6 @@
"title": "QueryMsg",
"oneOf": [
{
"description": "range queries",
"type": "object",
"required": [
"range_query"
Expand All @@ -240,7 +258,6 @@
"additionalProperties": false
},
{
"description": "admin queries",
"type": "object",
"required": [
"admin_query"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"title": "ExecuteMsg",
"oneOf": [
{
"description": "range operations",
"type": "object",
"required": [
"range_msg"
Expand All @@ -16,7 +15,6 @@
"additionalProperties": false
},
{
"description": "admin operations",
"type": "object",
"required": [
"admin_msg"
Expand Down Expand Up @@ -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
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"title": "QueryMsg",
"oneOf": [
{
"description": "range queries",
"type": "object",
"required": [
"range_query"
Expand All @@ -16,7 +15,6 @@
"additionalProperties": false
},
{
"description": "admin queries",
"type": "object",
"required": [
"admin_query"
Expand Down
34 changes: 6 additions & 28 deletions smart-contracts/osmosis/contracts/range-middleware/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,33 +60,11 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result<Response, ContractError> {
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))
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
use cosmwasm_std::StdError;
use cw2::VersionError;
use thiserror::Error;

#[derive(Error, Debug, PartialEq)]
pub enum ContractError {
#[error("{0}")]
Std(#[from] StdError),

#[error("{0}")]
Version(#[from] VersionError),

#[error("Unauthorized")]
Unauthorized {},

Expand Down
27 changes: 0 additions & 27 deletions smart-contracts/osmosis/contracts/range-middleware/src/helpers.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pub mod admin;
pub mod contract;
mod error;
pub mod helpers;
pub mod msg;
pub mod range;
pub mod state;
Expand Down

0 comments on commit fc5d737

Please sign in to comment.