From c31f4db1d1f8f421d89ad01206b572e280c033a0 Mon Sep 17 00:00:00 2001 From: nhpd Date: Tue, 15 Oct 2024 16:51:34 +0400 Subject: [PATCH] use neutron-std Order type for channels; fix some schema generation --- Cargo.lock | 4 ++-- contracts/marketmap/examples/schema.rs | 3 +-- contracts/marketmap/src/contract.rs | 11 +---------- contracts/marketmap/src/lib.rs | 2 +- contracts/marketmap/src/{query.rs => msg.rs} | 7 +++++++ .../neutron_interchain_queries/src/testing/tests.rs | 7 ++----- .../examples/neutron_interchain_txs-schema.rs | 2 +- contracts/neutron_interchain_txs/src/contract.rs | 4 ++-- contracts/neutron_interchain_txs/src/msg.rs | 4 ++-- .../examples/neutron_validator_test-schema.rs | 2 +- contracts/neutron_validator_test/src/contract.rs | 4 ++-- contracts/oracle/examples/schema.rs | 4 ++-- contracts/oracle/src/contract.rs | 11 +---------- contracts/oracle/src/lib.rs | 2 +- contracts/oracle/src/msg.rs | 7 +++++++ 15 files changed, 33 insertions(+), 41 deletions(-) rename contracts/marketmap/src/{query.rs => msg.rs} (60%) diff --git a/Cargo.lock b/Cargo.lock index 2507365..a1e93d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1128,7 +1128,7 @@ dependencies = [ [[package]] name = "neutron-sdk" version = "0.11.0" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#4841d0231fae18e6ac39571e9b8b2b1bcf67faf9" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#82e4e338ba92c3bd4d6f2f22c10aa597c09a7e3c" dependencies = [ "bech32 0.9.1", "chrono", @@ -1177,7 +1177,7 @@ dependencies = [ [[package]] name = "neutron-std-derive" version = "0.20.1" -source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#4841d0231fae18e6ac39571e9b8b2b1bcf67faf9" +source = "git+https://github.com/neutron-org/neutron-sdk?branch=feat/clean-bindings#82e4e338ba92c3bd4d6f2f22c10aa597c09a7e3c" dependencies = [ "itertools 0.10.5", "proc-macro2", diff --git a/contracts/marketmap/examples/schema.rs b/contracts/marketmap/examples/schema.rs index d83d7f1..f1eb66b 100644 --- a/contracts/marketmap/examples/schema.rs +++ b/contracts/marketmap/examples/schema.rs @@ -17,7 +17,6 @@ use std::fs::create_dir_all; use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; use marketmap::contract::InstantiateMsg; -use neutron_sdk::bindings::marketmap::query::MarketMapQuery; fn main() { let mut out_dir = current_dir().unwrap(); @@ -26,5 +25,5 @@ fn main() { remove_schemas(&out_dir).unwrap(); export_schema(&schema_for!(InstantiateMsg), &out_dir); - export_schema(&schema_for!(MarketMapQuery), &out_dir); + export_schema(&schema_for!(QueryMsg), &out_dir); } diff --git a/contracts/marketmap/src/contract.rs b/contracts/marketmap/src/contract.rs index 5ce50c2..7c55ee2 100644 --- a/contracts/marketmap/src/contract.rs +++ b/contracts/marketmap/src/contract.rs @@ -1,18 +1,9 @@ -use crate::query::QueryMsg; +use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; 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}; - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -pub struct InstantiateMsg {} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] -#[serde(rename_all = "snake_case")] -pub enum ExecuteMsg {} const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME")); const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); diff --git a/contracts/marketmap/src/lib.rs b/contracts/marketmap/src/lib.rs index f43d2b3..37088ba 100644 --- a/contracts/marketmap/src/lib.rs +++ b/contracts/marketmap/src/lib.rs @@ -1,2 +1,2 @@ pub mod contract; -mod query; +mod msg; diff --git a/contracts/marketmap/src/query.rs b/contracts/marketmap/src/msg.rs similarity index 60% rename from contracts/marketmap/src/query.rs rename to contracts/marketmap/src/msg.rs index 2f6ea25..95edcaa 100644 --- a/contracts/marketmap/src/query.rs +++ b/contracts/marketmap/src/msg.rs @@ -2,6 +2,13 @@ use neutron_std::types::slinky::types::v1::CurrencyPair; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +pub struct InstantiateMsg {} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] +#[serde(rename_all = "snake_case")] +pub enum ExecuteMsg {} + #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum QueryMsg { diff --git a/contracts/neutron_interchain_queries/src/testing/tests.rs b/contracts/neutron_interchain_queries/src/testing/tests.rs index 536d7ea..00ec3fe 100644 --- a/contracts/neutron_interchain_queries/src/testing/tests.rs +++ b/contracts/neutron_interchain_queries/src/testing/tests.rs @@ -32,10 +32,6 @@ use cosmwasm_std::{ from_json, to_json_binary, Addr, Binary, Coin, Decimal, Env, MessageInfo, OwnedDeps, StdError, Uint128, }; -use neutron_sdk::bindings::query::{ - NeutronQuery, QueryRegisteredQueryResponse, QueryRegisteredQueryResultResponse, -}; -use neutron_sdk::bindings::types::{decode_hex, Height}; use neutron_sdk::interchain_queries::helpers::decode_and_convert; use neutron_sdk::interchain_queries::types::{ QueryType, TransactionFilterItem, TransactionFilterOp, TransactionFilterValue, @@ -55,12 +51,13 @@ use neutron_sdk::interchain_queries::v047::types::{ ValidatorSigningInfo, WeightedVoteOption, DECIMAL_PLACES, RECIPIENT_FIELD, }; use neutron_sdk::NeutronError; +use neutron_std::types::neutron::interchainqueries::KvKey; use prost::Message as ProstMessage; use schemars::_serde_json::to_string; use std::ops::Mul; enum QueryParam { - Keys(Vec), + Keys(Vec), TransactionsFilter(String), } diff --git a/contracts/neutron_interchain_txs/examples/neutron_interchain_txs-schema.rs b/contracts/neutron_interchain_txs/examples/neutron_interchain_txs-schema.rs index 9169e7a..fad1537 100644 --- a/contracts/neutron_interchain_txs/examples/neutron_interchain_txs-schema.rs +++ b/contracts/neutron_interchain_txs/examples/neutron_interchain_txs-schema.rs @@ -14,8 +14,8 @@ use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; use neutron_interchain_txs::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; -use neutron_sdk::bindings::query::QueryInterchainAccountAddressResponse; use neutron_sdk::sudo::msg::SudoMsg; +use neutron_std::types::neutron::interchaintxs::v1::QueryInterchainAccountAddressResponse; use std::env::current_dir; use std::fs::create_dir_all; diff --git a/contracts/neutron_interchain_txs/src/contract.rs b/contracts/neutron_interchain_txs/src/contract.rs index 2b70a66..702f850 100644 --- a/contracts/neutron_interchain_txs/src/contract.rs +++ b/contracts/neutron_interchain_txs/src/contract.rs @@ -43,7 +43,6 @@ use crate::storage::{ INTEGRATION_TESTS_SUDO_SUBMSG_FAILURE_MOCK, INTERCHAIN_ACCOUNTS, REGISTER_FEE, REGISTER_ICA_REPLY_ID, SUDO_FAILING_SUBMSG_REPLY_ID, SUDO_PAYLOAD_REPLY_ID, TEST_COUNTER_ITEM, }; -use neutron_sdk::bindings::msg::ChannelOrdering; use neutron_sdk::interchain_txs::helpers::{ decode_message_response, get_port_id, register_interchain_account, submit_tx, }; @@ -51,6 +50,7 @@ use neutron_sdk::interchain_txs::v047::helpers::decode_acknowledgement_response; use neutron_sdk::sudo::msg::{RequestPacket, SudoMsg}; use neutron_sdk::NeutronResult; use neutron_std::shim::Any; +use neutron_std::types::ibc::core::channel::v1::Order; use neutron_std::types::neutron::contractmanager::MsgResubmitFailure; use neutron_std::types::neutron::feerefunder::Fee; use neutron_std::types::neutron::interchaintxs::v1::{ @@ -313,7 +313,7 @@ fn execute_register_ica( env: Env, connection_id: String, interchain_account_id: String, - ordering: Option, + ordering: Option, ) -> StdResult { let register_fee = REGISTER_FEE.load(deps.storage)?; let register = register_interchain_account( diff --git a/contracts/neutron_interchain_txs/src/msg.rs b/contracts/neutron_interchain_txs/src/msg.rs index a6ed4b0..7dd4d87 100644 --- a/contracts/neutron_interchain_txs/src/msg.rs +++ b/contracts/neutron_interchain_txs/src/msg.rs @@ -1,6 +1,6 @@ use crate::storage::{AcknowledgementResult, IntegrationTestsSudoFailureMock}; use cosmwasm_std::Uint128; -use neutron_sdk::bindings::msg::ChannelOrdering; +use neutron_std::types::ibc::core::channel::v1::Order; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -39,7 +39,7 @@ pub enum ExecuteMsg { Register { connection_id: String, interchain_account_id: String, - ordering: Option, + ordering: Option, }, SetFees { denom: String, diff --git a/contracts/neutron_validator_test/examples/neutron_validator_test-schema.rs b/contracts/neutron_validator_test/examples/neutron_validator_test-schema.rs index cb365a0..9b83441 100644 --- a/contracts/neutron_validator_test/examples/neutron_validator_test-schema.rs +++ b/contracts/neutron_validator_test/examples/neutron_validator_test-schema.rs @@ -13,8 +13,8 @@ // limitations under the License. use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; -use neutron_sdk::bindings::query::QueryInterchainAccountAddressResponse; use neutron_sdk::sudo::msg::SudoMsg; +use neutron_std::types::neutron::interchaintxs::v1::QueryInterchainAccountAddressResponse; use neutron_validators_test::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; use std::env::current_dir; use std::fs::create_dir_all; diff --git a/contracts/neutron_validator_test/src/contract.rs b/contracts/neutron_validator_test/src/contract.rs index 831c3ee..1924e24 100644 --- a/contracts/neutron_validator_test/src/contract.rs +++ b/contracts/neutron_validator_test/src/contract.rs @@ -34,7 +34,6 @@ use cosmwasm_std::{ Response, StdError, StdResult, SubMsg, Uint128, }; use cw2::set_contract_version; -use neutron_sdk::bindings::msg::ChannelOrdering; use neutron_sdk::interchain_queries::helpers::remove_interchain_query as helpers_remove_interchain_query; use neutron_sdk::interchain_queries::queries::get_registered_query; use neutron_sdk::interchain_queries::types::{ @@ -53,6 +52,7 @@ use neutron_sdk::sudo::msg::{RequestPacket, SudoMsg}; use neutron_sdk::{NeutronError, NeutronResult}; use neutron_std::shim::Any; use neutron_std::types::cosmos::base::v1beta1::Coin as CosmosCoin; +use neutron_std::types::ibc::core::channel::v1::Order; use neutron_std::types::ibc::core::client::v1::Height; use neutron_std::types::neutron::feerefunder::Fee; use neutron_std::types::neutron::interchainqueries::RegisteredQuery; @@ -290,7 +290,7 @@ fn execute_register_ica( connection_id, interchain_account_id.clone(), vec![], - Some(ChannelOrdering::OrderOrdered), + Some(Order::Ordered), ); let key = get_port_id(env.contract.address.as_str(), &interchain_account_id); INTERCHAIN_ACCOUNTS.save(deps.storage, key, &None)?; diff --git a/contracts/oracle/examples/schema.rs b/contracts/oracle/examples/schema.rs index 5217d6d..8b54f90 100644 --- a/contracts/oracle/examples/schema.rs +++ b/contracts/oracle/examples/schema.rs @@ -16,8 +16,8 @@ use std::env::current_dir; use std::fs::create_dir_all; use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; -use neutron_sdk::bindings::oracle::query::OracleQuery; use oracle::contract::InstantiateMsg; +use oracle::msg::QueryMsg; fn main() { let mut out_dir = current_dir().unwrap(); @@ -26,5 +26,5 @@ fn main() { remove_schemas(&out_dir).unwrap(); export_schema(&schema_for!(InstantiateMsg), &out_dir); - export_schema(&schema_for!(OracleQuery), &out_dir); + export_schema(&schema_for!(QueryMsg), &out_dir); } diff --git a/contracts/oracle/src/contract.rs b/contracts/oracle/src/contract.rs index c7460d2..eb683c1 100644 --- a/contracts/oracle/src/contract.rs +++ b/contracts/oracle/src/contract.rs @@ -1,19 +1,10 @@ -use crate::msg::QueryMsg; +use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; 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::oracle::v1::OracleQuerier; use neutron_std::types::slinky::types::v1::CurrencyPair; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -pub struct InstantiateMsg {} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] -#[serde(rename_all = "snake_case")] -pub enum ExecuteMsg {} const CONTRACT_NAME: &str = concat!("crates.io:neutron-contracts__", env!("CARGO_PKG_NAME")); const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); diff --git a/contracts/oracle/src/lib.rs b/contracts/oracle/src/lib.rs index 37088ba..112ecad 100644 --- a/contracts/oracle/src/lib.rs +++ b/contracts/oracle/src/lib.rs @@ -1,2 +1,2 @@ pub mod contract; -mod msg; +pub mod msg; diff --git a/contracts/oracle/src/msg.rs b/contracts/oracle/src/msg.rs index 506253f..98eb798 100644 --- a/contracts/oracle/src/msg.rs +++ b/contracts/oracle/src/msg.rs @@ -1,6 +1,13 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +pub struct InstantiateMsg {} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] +#[serde(rename_all = "snake_case")] +pub enum ExecuteMsg {} + #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum QueryMsg {