diff --git a/Cargo.lock b/Cargo.lock index 8dfc848..9fb8b2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1090,6 +1090,7 @@ dependencies = [ "cosmwasm-std 2.1.4", "cw2 2.0.0", "neutron-sdk", + "neutron-std", "schemars", "serde", ] @@ -1152,7 +1153,7 @@ dependencies = [ [[package]] name = "neutron-std" version = "4.2.2-rc" -source = "git+https://github.com/neutron-org/neutron-std?branch=feat/clean-bindings#f8168e5727bf8d397b144e700b9c22af40c9710c" +source = "git+https://github.com/neutron-org/neutron-std?branch=feat/clean-bindings#1e61039a6c59bc58292029c00bf4f7758dc31b4f" dependencies = [ "bech32 0.9.1", "chrono", @@ -1188,7 +1189,7 @@ dependencies = [ [[package]] name = "neutron-std-derive" version = "0.20.1" -source = "git+https://github.com/neutron-org/neutron-std?branch=feat/clean-bindings#f8168e5727bf8d397b144e700b9c22af40c9710c" +source = "git+https://github.com/neutron-org/neutron-std?branch=feat/clean-bindings#1e61039a6c59bc58292029c00bf4f7758dc31b4f" dependencies = [ "itertools 0.10.5", "proc-macro2", diff --git a/contracts/marketmap/Cargo.toml b/contracts/marketmap/Cargo.toml index a18ca2d..9153ceb 100644 --- a/contracts/marketmap/Cargo.toml +++ b/contracts/marketmap/Cargo.toml @@ -36,6 +36,7 @@ cw2 = { workspace = true } schemars = { workspace = true } serde = { version = "1.0.180", default-features = false, features = ["derive"] } neutron-sdk = { workspace = true } +neutron-std = { workspace = true } [dev-dependencies] cosmwasm-schema = { workspace = true } diff --git a/contracts/marketmap/src/contract.rs b/contracts/marketmap/src/contract.rs index eee9e82..66e6f40 100644 --- a/contracts/marketmap/src/contract.rs +++ b/contracts/marketmap/src/contract.rs @@ -2,8 +2,10 @@ use cosmwasm_std::{ entry_point, to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, }; use cw2::set_contract_version; +use neutron_std::types::slinky::marketmap::v1::MarketmapQuerier; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +use crate::query::QueryMsg; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] pub struct InstantiateMsg {} @@ -38,27 +40,24 @@ pub fn execute( } #[entry_point] -pub fn query(deps: Deps, env: Env, msg: MarketMapQuery) -> StdResult { +pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { query_marketmap(deps, env, msg) } -fn query_marketmap(deps: Deps, _env: Env, msg: MarketMapQuery) -> StdResult { +fn query_marketmap(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult { + let querier = MarketmapQuerier::new(&deps.querier); match msg { - MarketMapQuery::Params { .. } => { - let query_response: ParamsResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) + QueryMsg::Params { .. } => { + to_json_binary(&querier.params()?) } - MarketMapQuery::LastUpdated { .. } => { - let query_response: LastUpdatedResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) + QueryMsg::LastUpdated { .. } => { + to_json_binary(&querier.last_updated()?) } - MarketMapQuery::MarketMap { .. } => { - let query_response: MarketMapResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) + QueryMsg::MarketMap { .. } => { + to_json_binary(&querier.market_map()?) } - MarketMapQuery::Market { .. } => { - let query_response: MarketResponse = deps.querier.query(&msg.into())?; - to_json_binary(&query_response) + QueryMsg::Market { currency_pair } => { + to_json_binary(&querier.market(Some(currency_pair))?) } } } diff --git a/contracts/marketmap/src/lib.rs b/contracts/marketmap/src/lib.rs index 2943dbb..f43d2b3 100644 --- a/contracts/marketmap/src/lib.rs +++ b/contracts/marketmap/src/lib.rs @@ -1 +1,2 @@ pub mod contract; +mod query; diff --git a/contracts/marketmap/src/query.rs b/contracts/marketmap/src/query.rs new file mode 100644 index 0000000..0140fb0 --- /dev/null +++ b/contracts/marketmap/src/query.rs @@ -0,0 +1,14 @@ +use neutron_std::types::slinky::types::v1::CurrencyPair; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[serde(rename_all = "snake_case")] +pub enum QueryMsg { + Params { }, + LastUpdated { }, + MarketMap { }, + Market { + currency_pair: CurrencyPair, + }, +} \ No newline at end of file diff --git a/contracts/neutron_validator_test/src/contract.rs b/contracts/neutron_validator_test/src/contract.rs index 85ebfb6..38def28 100644 --- a/contracts/neutron_validator_test/src/contract.rs +++ b/contracts/neutron_validator_test/src/contract.rs @@ -27,7 +27,6 @@ use cosmwasm_std::{coin, to_json_binary, Addr, Binary, CosmosMsg, CustomQuery, D use cw2::set_contract_version; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; - use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; use neutron_sdk::interchain_queries::queries::get_registered_query; use neutron_sdk::interchain_queries::types::{ @@ -38,7 +37,7 @@ use neutron_sdk::interchain_queries::v045::types::{COSMOS_SDK_TRANSFER_MSG_URL, use neutron_sdk::interchain_queries::v045::{ new_register_balances_query_msg, new_register_transfers_query_msg, }; -use neutron_sdk::interchain_txs::helpers::{decode_message_response, get_port_id}; +use neutron_sdk::interchain_txs::helpers::{decode_message_response, get_port_id, register_interchain_account}; use neutron_sdk::interchain_txs::v047::helpers::decode_acknowledgement_response; use neutron_sdk::sudo::msg::{RequestPacket, SudoMsg}; use neutron_sdk::{NeutronError, NeutronResult}; @@ -52,6 +51,7 @@ use crate::storage::{ }; use neutron_std::types::cosmos::base::v1beta1::Coin as CosmosCoin; use neutron_std::types::neutron::interchaintxs::v1::{InterchaintxsQuerier, MsgSubmitTxResponse}; +use neutron_sdk::interchain_queries::helpers::{update_interchain_query as helpers_update_interchain_query, remove_interchain_query as helpers_remove_interchain_query}; // Default timeout for SubmitTX is two weeks const DEFAULT_TIMEOUT_SECONDS: u64 = 60 * 60 * 24 * 7 * 2; @@ -258,11 +258,12 @@ fn execute_register_ica( interchain_account_id: String, ) -> NeutronResult { let register = register_interchain_account( + env.contract.address.clone(), connection_id, interchain_account_id.clone(), - None, + vec![], Some(ChannelOrdering::OrderOrdered), - ); + )?; let key = get_port_id(env.contract.address.as_str(), &interchain_account_id); INTERCHAIN_ACCOUNTS.save(deps.storage, key, &None)?; Ok(Response::new().add_message(register)) @@ -428,7 +429,7 @@ pub fn register_transfers_query( } pub fn remove_interchain_query(contract: Addr, query_id: u64) -> NeutronResult { - let remove_msg = remove_interchain_query_helper(contract, query_id)?; + let remove_msg = helpers_remove_interchain_query(contract, query_id)?; Ok(Response::new().add_message(remove_msg)) }