diff --git a/Cargo.toml b/Cargo.toml index edae905e6..3d921a5f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,7 @@ members = [ # Mock contracts # "contracts/mock/mock_band", //TODO: migrate to v1 - # "contracts/mock/mock_secretswap_pair", //TODO: migrate to v1 + "contracts/mock/mock_secretswap_pair", "contracts/mock/mock_sienna_pair", # "contracts/mock/mock_adapter", //TODO: migrate to v1 "contracts/mock/mock_stkd_derivative", diff --git a/archived-contracts/mock_secretswap_pair/.cargo/config b/contracts/mock/mock_secretswap_pair/.cargo/config similarity index 100% rename from archived-contracts/mock_secretswap_pair/.cargo/config rename to contracts/mock/mock_secretswap_pair/.cargo/config diff --git a/archived-contracts/mock_secretswap_pair/.circleci/config.yml b/contracts/mock/mock_secretswap_pair/.circleci/config.yml similarity index 100% rename from archived-contracts/mock_secretswap_pair/.circleci/config.yml rename to contracts/mock/mock_secretswap_pair/.circleci/config.yml diff --git a/archived-contracts/mock_secretswap_pair/Cargo.toml b/contracts/mock/mock_secretswap_pair/Cargo.toml similarity index 87% rename from archived-contracts/mock_secretswap_pair/Cargo.toml rename to contracts/mock/mock_secretswap_pair/Cargo.toml index 00380ef0f..43155f375 100644 --- a/archived-contracts/mock_secretswap_pair/Cargo.toml +++ b/contracts/mock/mock_secretswap_pair/Cargo.toml @@ -23,9 +23,8 @@ backtraces = ["shade-protocol/backtraces"] debug-print = ["shade-protocol/debug-print"] [dependencies] -bincode = "1.3.1" shade-protocol = { version = "0.1.0", path = "../../../packages/shade_protocol", features = [ "dex", + "storage_plus", ] } -schemars = "0.7" -serde = { version = "1.0.103", default-features = false, features = ["derive"] } +cosmwasm-schema = "1.1.5" \ No newline at end of file diff --git a/archived-contracts/mock_secretswap_pair/Makefile b/contracts/mock/mock_secretswap_pair/Makefile similarity index 100% rename from archived-contracts/mock_secretswap_pair/Makefile rename to contracts/mock/mock_secretswap_pair/Makefile diff --git a/archived-contracts/mock_secretswap_pair/README.md b/contracts/mock/mock_secretswap_pair/README.md similarity index 100% rename from archived-contracts/mock_secretswap_pair/README.md rename to contracts/mock/mock_secretswap_pair/README.md diff --git a/archived-contracts/mock_secretswap_pair/src/contract.rs b/contracts/mock/mock_secretswap_pair/src/contract.rs similarity index 75% rename from archived-contracts/mock_secretswap_pair/src/contract.rs rename to contracts/mock/mock_secretswap_pair/src/contract.rs index c9127e90a..21b277885 100644 --- a/archived-contracts/mock_secretswap_pair/src/contract.rs +++ b/contracts/mock/mock_secretswap_pair/src/contract.rs @@ -1,20 +1,17 @@ -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; +use cosmwasm_schema::cw_serde; use shade_protocol::{ c_std::{ to_binary, Addr, - Api, Binary, Deps, DepsMut, Env, - Querier, Response, StdError, StdResult, - Storage, Uint128, + shd_entry_point, }, contract_interfaces::{ dex::{ @@ -29,38 +26,22 @@ use shade_protocol::{ Token, }, }, - oracles::band::{InstantiateMsg, ReferenceData}, + oracles::band::InstantiateMsg, }, utils::asset::Contract, }; -use shade_protocol::storage::{singleton, singleton_read, ReadonlySingleton, Singleton}; +use crate::storage::{POOL, PAIR_INFO}; -pub static PAIR_INFO: &[u8] = b"pair_info"; -pub static POOL: &[u8] = b"pool"; - -pub fn pair_info_r(storage: &dyn Storage) -> ReadonlySingleton { - singleton_read(storage, PAIR_INFO) -} - -pub fn pair_info_w(storage: &mut dyn Storage) -> Singleton { - singleton(storage, PAIR_INFO) -} - -pub fn pool_r(storage: &dyn Storage) -> ReadonlySingleton { - singleton_read(storage, POOL) -} - -pub fn pool_w(storage: &mut dyn Storage) -> Singleton { - singleton(storage, POOL) -} - -pub fn init(_deps: DepsMut, _env: Env, _msg: InstantiateMsg) -> StdResult { +pub fn instantiate( + _deps: DepsMut, + _env: Env, + _msg: InstantiateMsg +) -> StdResult { Ok(Response::default()) } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum ExecuteMsg { MockPool { token_a: Contract, @@ -70,7 +51,8 @@ pub enum ExecuteMsg { }, } -pub fn handle(deps: DepsMut, _env: Env, msg: ExecuteMsg) -> StdResult { +#[shd_entry_point] +pub fn execute(deps: DepsMut, _env: Env, msg: ExecuteMsg) -> StdResult { return match msg { ExecuteMsg::MockPool { token_a, @@ -94,7 +76,7 @@ pub fn handle(deps: DepsMut, _env: Env, msg: ExecuteMsg) -> StdResult }, }, ]; - pool_w(deps.storage).save(&PoolResponse { + POOL.save(deps.storage, &PoolResponse { assets: vec![ Asset { amount: amount_a, @@ -108,7 +90,7 @@ pub fn handle(deps: DepsMut, _env: Env, msg: ExecuteMsg) -> StdResult total_share: Uint128::zero(), })?; - pair_info_w(deps.storage).save(&PairResponse { + PAIR_INFO.save(deps.storage, &PairResponse { asset_infos, contract_addr: Addr::unchecked("".to_string()), liquidity_token: Addr::unchecked("".to_string()), @@ -125,12 +107,13 @@ pub fn handle(deps: DepsMut, _env: Env, msg: ExecuteMsg) -> StdResult }; } +#[shd_entry_point] pub fn query(deps: Deps, msg: PairQuery) -> StdResult { match msg { - PairQuery::Pool {} => to_binary(&pool_r(deps.storage).load()?), - PairQuery::Pair {} => to_binary(&pair_info_r(deps.storage).load()?), + PairQuery::Pool {} => to_binary(&POOL.load(deps.storage)?), + PairQuery::Pair {} => to_binary(&PAIR_INFO.load(deps.storage)?), PairQuery::Simulation { offer_asset } => { - let pool = pool_r(deps.storage).load()?; + let pool = POOL.load(deps.storage)?; if pool.assets[0].info == offer_asset.info { /* diff --git a/archived-contracts/mock_secretswap_pair/src/lib.rs b/contracts/mock/mock_secretswap_pair/src/lib.rs similarity index 98% rename from archived-contracts/mock_secretswap_pair/src/lib.rs rename to contracts/mock/mock_secretswap_pair/src/lib.rs index d7d6c200e..613dc6d0d 100644 --- a/archived-contracts/mock_secretswap_pair/src/lib.rs +++ b/contracts/mock/mock_secretswap_pair/src/lib.rs @@ -1,4 +1,5 @@ pub mod contract; +pub mod storage; #[cfg(target_arch = "wasm32")] mod wasm { diff --git a/contracts/mock/mock_secretswap_pair/src/storage.rs b/contracts/mock/mock_secretswap_pair/src/storage.rs new file mode 100644 index 000000000..8c3079b0e --- /dev/null +++ b/contracts/mock/mock_secretswap_pair/src/storage.rs @@ -0,0 +1,8 @@ +use shade_protocol::secret_storage_plus::Item; +use shade_protocol::contract_interfaces::dex::secretswap::{ + PairResponse, + PoolResponse, +}; + +pub const PAIR_INFO: Item = Item::new("pair_info"); +pub const POOL: Item = Item::new("pool"); \ No newline at end of file