From 0abc6312d19b74ea1c5e64cbb508481dc1c134aa Mon Sep 17 00:00:00 2001 From: Aleksandr Pismenskiy Date: Wed, 16 Oct 2024 16:45:36 +0300 Subject: [PATCH] add adminmodule types generation --- .../types/cosmos/adminmodule/adminmodule.rs | 301 ++++++++++++++++++ .../src/types/cosmos/adminmodule/mod.rs | 1 + packages/neutron-std/src/types/cosmos/mod.rs | 1 + .../neutron-std/src/types/neutron/dex/mod.rs | 18 ++ proto-build/src/code_generator.rs | 31 +- proto-build/src/main.rs | 14 + 6 files changed, 351 insertions(+), 15 deletions(-) create mode 100644 packages/neutron-std/src/types/cosmos/adminmodule/adminmodule.rs create mode 100644 packages/neutron-std/src/types/cosmos/adminmodule/mod.rs diff --git a/packages/neutron-std/src/types/cosmos/adminmodule/adminmodule.rs b/packages/neutron-std/src/types/cosmos/adminmodule/adminmodule.rs new file mode 100644 index 0000000..85201b9 --- /dev/null +++ b/packages/neutron-std/src/types/cosmos/adminmodule/adminmodule.rs @@ -0,0 +1,301 @@ +use neutron_std_derive::CosmwasmExt; +/// GenesisState defines the adminmodule module's genesis state. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive( + Clone, + PartialEq, + Eq, + ::prost::Message, + ::serde::Serialize, + ::serde::Deserialize, + ::schemars::JsonSchema, + CosmwasmExt, +)] +#[proto_message(type_url = "/cosmos.adminmodule.adminmodule.GenesisState")] +pub struct GenesisState { + #[prost(string, repeated, tag = "1")] + pub admins: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive( + Clone, + PartialEq, + Eq, + ::prost::Message, + ::serde::Serialize, + ::serde::Deserialize, + ::schemars::JsonSchema, + CosmwasmExt, +)] +#[proto_message(type_url = "/cosmos.adminmodule.adminmodule.QueryAdminsRequest")] +#[proto_query( + path = "/cosmos.adminmodule.adminmodule.Query/Admins", + response_type = QueryAdminsResponse +)] +pub struct QueryAdminsRequest {} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive( + Clone, + PartialEq, + Eq, + ::prost::Message, + ::serde::Serialize, + ::serde::Deserialize, + ::schemars::JsonSchema, + CosmwasmExt, +)] +#[proto_message(type_url = "/cosmos.adminmodule.adminmodule.QueryAdminsResponse")] +pub struct QueryAdminsResponse { + #[prost(string, repeated, tag = "1")] + pub admins: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive( + Clone, + PartialEq, + Eq, + ::prost::Message, + ::serde::Serialize, + ::serde::Deserialize, + ::schemars::JsonSchema, + CosmwasmExt, +)] +#[proto_message(type_url = "/cosmos.adminmodule.adminmodule.QueryArchivedProposalsRequest")] +#[proto_query( + path = "/cosmos.adminmodule.adminmodule.Query/ArchivedProposals", + response_type = QueryArchivedProposalsResponse +)] +pub struct QueryArchivedProposalsRequest {} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive( + Clone, + PartialEq, + Eq, + ::prost::Message, + ::serde::Serialize, + ::serde::Deserialize, + ::schemars::JsonSchema, + CosmwasmExt, +)] +#[proto_message(type_url = "/cosmos.adminmodule.adminmodule.QueryArchivedProposalsLegacyRequest")] +#[proto_query( + path = "/cosmos.adminmodule.adminmodule.Query/ArchivedProposalsLegacy", + response_type = QueryArchivedProposalsLegacyResponse +)] +pub struct QueryArchivedProposalsLegacyRequest {} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive( + Clone, + PartialEq, + Eq, + ::prost::Message, + ::serde::Serialize, + ::serde::Deserialize, + ::schemars::JsonSchema, + CosmwasmExt, +)] +#[proto_message(type_url = "/cosmos.adminmodule.adminmodule.QueryProposalsResponse")] +pub struct QueryProposalsResponse { + #[prost(message, repeated, tag = "1")] + pub proposals: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive( + Clone, + PartialEq, + Eq, + ::prost::Message, + ::serde::Serialize, + ::serde::Deserialize, + ::schemars::JsonSchema, + CosmwasmExt, +)] +#[proto_message(type_url = "/cosmos.adminmodule.adminmodule.QueryArchivedProposalsResponse")] +pub struct QueryArchivedProposalsResponse { + #[prost(message, repeated, tag = "1")] + pub proposals: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive( + Clone, + PartialEq, + Eq, + ::prost::Message, + ::serde::Serialize, + ::serde::Deserialize, + ::schemars::JsonSchema, + CosmwasmExt, +)] +#[proto_message(type_url = "/cosmos.adminmodule.adminmodule.QueryArchivedProposalsLegacyResponse")] +pub struct QueryArchivedProposalsLegacyResponse { + #[prost(message, repeated, tag = "1")] + pub proposals_legacy: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive( + Clone, + PartialEq, + Eq, + ::prost::Message, + ::serde::Serialize, + ::serde::Deserialize, + ::schemars::JsonSchema, + CosmwasmExt, +)] +#[proto_message(type_url = "/cosmos.adminmodule.adminmodule.MsgDeleteAdmin")] +pub struct MsgDeleteAdmin { + #[prost(string, tag = "1")] + pub creator: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub admin: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive( + Clone, + PartialEq, + Eq, + ::prost::Message, + ::serde::Serialize, + ::serde::Deserialize, + ::schemars::JsonSchema, + CosmwasmExt, +)] +#[proto_message(type_url = "/cosmos.adminmodule.adminmodule.MsgDeleteAdminResponse")] +pub struct MsgDeleteAdminResponse {} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive( + Clone, + PartialEq, + Eq, + ::prost::Message, + ::serde::Serialize, + ::serde::Deserialize, + ::schemars::JsonSchema, + CosmwasmExt, +)] +#[proto_message(type_url = "/cosmos.adminmodule.adminmodule.MsgAddAdmin")] +pub struct MsgAddAdmin { + #[prost(string, tag = "1")] + pub creator: ::prost::alloc::string::String, + #[prost(string, tag = "2")] + pub admin: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive( + Clone, + PartialEq, + Eq, + ::prost::Message, + ::serde::Serialize, + ::serde::Deserialize, + ::schemars::JsonSchema, + CosmwasmExt, +)] +#[proto_message(type_url = "/cosmos.adminmodule.adminmodule.MsgAddAdminResponse")] +pub struct MsgAddAdminResponse {} +/// MsgSubmitProposalLegacy defines an sdk.Msg type that supports submitting arbitrary +/// proposal Content. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive( + Clone, + PartialEq, + Eq, + ::prost::Message, + ::serde::Serialize, + ::serde::Deserialize, + ::schemars::JsonSchema, + CosmwasmExt, +)] +#[proto_message(type_url = "/cosmos.adminmodule.adminmodule.MsgSubmitProposalLegacy")] +pub struct MsgSubmitProposalLegacy { + #[prost(message, optional, tag = "1")] + pub content: ::core::option::Option, + #[prost(string, tag = "2")] + pub proposer: ::prost::alloc::string::String, +} +/// MsgSubmitProposalLegacyResponse defines the Msg/SubmitProposalLegacy response type. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive( + Clone, + PartialEq, + Eq, + ::prost::Message, + ::serde::Serialize, + ::serde::Deserialize, + ::schemars::JsonSchema, + CosmwasmExt, +)] +#[proto_message(type_url = "/cosmos.adminmodule.adminmodule.MsgSubmitProposalLegacyResponse")] +pub struct MsgSubmitProposalLegacyResponse { + #[prost(uint64, tag = "1")] + #[serde(alias = "proposalID")] + #[serde( + serialize_with = "crate::serde::as_str::serialize", + deserialize_with = "crate::serde::as_str::deserialize" + )] + pub proposal_id: u64, +} +/// MsgSubmitProposal defines an sdk.Msg type that supports submitting arbitrary +/// proposal Content. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive( + Clone, + PartialEq, + Eq, + ::prost::Message, + ::serde::Serialize, + ::serde::Deserialize, + ::schemars::JsonSchema, + CosmwasmExt, +)] +#[proto_message(type_url = "/cosmos.adminmodule.adminmodule.MsgSubmitProposal")] +pub struct MsgSubmitProposal { + /// messages are the arbitrary messages to be executed if proposal passes. + #[prost(message, repeated, tag = "1")] + pub messages: ::prost::alloc::vec::Vec, + #[prost(string, tag = "2")] + pub proposer: ::prost::alloc::string::String, +} +/// MsgSubmitProposalResponse defines the Msg/SubmitProposal response type. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive( + Clone, + PartialEq, + Eq, + ::prost::Message, + ::serde::Serialize, + ::serde::Deserialize, + ::schemars::JsonSchema, + CosmwasmExt, +)] +#[proto_message(type_url = "/cosmos.adminmodule.adminmodule.MsgSubmitProposalResponse")] +pub struct MsgSubmitProposalResponse { + #[prost(uint64, tag = "1")] + #[serde(alias = "proposalID")] + #[serde( + serialize_with = "crate::serde::as_str::serialize", + deserialize_with = "crate::serde::as_str::deserialize" + )] + pub proposal_id: u64, +} +pub struct AdminmoduleQuerier<'a, Q: cosmwasm_std::CustomQuery> { + querier: &'a cosmwasm_std::QuerierWrapper<'a, Q>, +} +impl<'a, Q: cosmwasm_std::CustomQuery> AdminmoduleQuerier<'a, Q> { + pub fn new(querier: &'a cosmwasm_std::QuerierWrapper<'a, Q>) -> Self { + Self { querier } + } + pub fn admins(&self) -> Result { + QueryAdminsRequest {}.query(self.querier) + } + pub fn archived_proposals( + &self, + ) -> Result { + QueryArchivedProposalsRequest {}.query(self.querier) + } + pub fn archived_proposals_legacy( + &self, + ) -> Result { + QueryArchivedProposalsLegacyRequest {}.query(self.querier) + } +} diff --git a/packages/neutron-std/src/types/cosmos/adminmodule/mod.rs b/packages/neutron-std/src/types/cosmos/adminmodule/mod.rs new file mode 100644 index 0000000..ec92257 --- /dev/null +++ b/packages/neutron-std/src/types/cosmos/adminmodule/mod.rs @@ -0,0 +1 @@ +pub mod adminmodule; diff --git a/packages/neutron-std/src/types/cosmos/mod.rs b/packages/neutron-std/src/types/cosmos/mod.rs index 1363323..9f8d57c 100644 --- a/packages/neutron-std/src/types/cosmos/mod.rs +++ b/packages/neutron-std/src/types/cosmos/mod.rs @@ -1,3 +1,4 @@ +pub mod adminmodule; pub mod app; pub mod auth; pub mod authz; diff --git a/packages/neutron-std/src/types/neutron/dex/mod.rs b/packages/neutron-std/src/types/neutron/dex/mod.rs index 007b04f..862c629 100644 --- a/packages/neutron-std/src/types/neutron/dex/mod.rs +++ b/packages/neutron-std/src/types/neutron/dex/mod.rs @@ -82,10 +82,18 @@ pub struct PoolReserves { pub key: ::core::option::Option, #[prost(string, tag = "2")] pub reserves_maker_denom: ::prost::alloc::string::String, + /// DEPRECATED: price_taker_to_maker will be removed in future release, `maker_price` should always be used. + #[deprecated] #[prost(string, tag = "3")] pub price_taker_to_maker: ::prost::alloc::string::String, + /// DEPRECATED: price_opposite_taker_maker was an internal implementation detail and will be removed in a future release. + /// It is being kept strictly for backwards compatibility. The actual field value is unused. + #[deprecated] #[prost(string, tag = "4")] pub price_opposite_taker_to_maker: ::prost::alloc::string::String, + /// This is the price of the PoolReserves denominated in the opposite token. (ie. 1 TokenA with a maker_price of 10 is worth 10 TokenB ) + #[prost(string, tag = "5")] + pub maker_price: ::prost::alloc::string::String, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive( @@ -213,8 +221,13 @@ pub struct LimitOrderTranche { /// Order deletion still functions the same and the orders will be deleted at the end of the block #[prost(message, optional, tag = "6")] pub expiration_time: ::core::option::Option, + /// DEPRECATED: price_taker_to_maker will be removed in future release, `maker_price` should always be used. + #[deprecated] #[prost(string, tag = "7")] pub price_taker_to_maker: ::prost::alloc::string::String, + /// This is the price of the LimitOrder denominated in the opposite token. (ie. 1 TokenA with a maker_price of 10 is worth 10 TokenB ) + #[prost(string, tag = "8")] + pub maker_price: ::prost::alloc::string::String, } /// Params defines the parameters for the module. #[allow(clippy::derive_partial_eq_without_eq)] @@ -454,6 +467,11 @@ pub struct MsgPlaceLimitOrder { pub max_amount_out: ::prost::alloc::string::String, #[prost(string, tag = "11")] pub limit_sell_price: ::prost::alloc::string::String, + /// min_average_sell_price is an optional parameter that sets a required minimum average price for the entire trade. + /// if the min_average_sell_price is not met the trade will fail. + /// If min_average_sell_price is omitted limit_sell_price will be used instead + #[prost(string, tag = "12")] + pub min_average_sell_price: ::prost::alloc::string::String, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive( diff --git a/proto-build/src/code_generator.rs b/proto-build/src/code_generator.rs index c91d529..4fca091 100644 --- a/proto-build/src/code_generator.rs +++ b/proto-build/src/code_generator.rs @@ -125,21 +125,22 @@ impl CodeGenerator { // Compile proto files for each file in `protos` variable // `buf generate —template {` for project in all_related_projects { - let buf_root = if project.name == "cosmos" || project.name == "ics23" { - self.root.join(&project.project_dir).join("proto") - } else { - WalkDir::new(&self.root.join(&project.project_dir)) - .into_iter() - .filter_map(|e| e.ok()) - .find(|e| { - e.file_name() - .to_str() - .map(|s| s == "buf.yaml" || s == "buf.yml") - .unwrap_or(false) - }) - .map(|e| e.path().parent().unwrap().to_path_buf()) - .unwrap() - }; + let buf_root = + if project.name == "cosmos" || project.name == "ics23" || project.name == "admin" { + self.root.join(&project.project_dir).join("proto") + } else { + WalkDir::new(&self.root.join(&project.project_dir)) + .into_iter() + .filter_map(|e| e.ok()) + .find(|e| { + e.file_name() + .to_str() + .map(|s| s == "buf.yaml" || s == "buf.yml") + .unwrap_or(false) + }) + .map(|e| e.path().parent().unwrap().to_path_buf()) + .unwrap() + }; debug!("buf_root for project {:?}: {:?}", project.name, buf_root); diff --git a/proto-build/src/main.rs b/proto-build/src/main.rs index 661c056..ec805c4 100644 --- a/proto-build/src/main.rs +++ b/proto-build/src/main.rs @@ -18,6 +18,7 @@ const IBC_GO_REPO: &str = "https://github.com/cosmos/ibc-go.git"; const ICS23_REPO: &str = "https://github.com/cosmos/ics23.git"; const FEEMARKET_REPO: &str = "https://github.com/skip-mev/feemarket.git"; const SLINKY_REPO: &str = "https://github.com/skip-mev/slinky.git"; +const ADMIN_MODULE_REPO: &str = "https://github.com/neutron-org/admin-module.git"; /// The Cosmos SDK commit or tag to be cloned and used to build the proto files const COSMOS_SDK_REV: &str = "v0.50.9-neutron"; @@ -41,6 +42,8 @@ const FEEMARKET_REV: &str = "v1.1.1"; const SLINKY_REV: &str = "v1.0.3"; +const ADMIN_MODULE_REV: &str = "v2.0.2"; + // All paths must end with a / and either be absolute or include a ./ to reference the current // working directory. @@ -60,6 +63,8 @@ const ICS23_DIR: &str = "../dependencies/ics23/"; const FEEMARKET_DIR: &str = "../dependencies/feemarket/"; /// Directory where the slinky repo is located const SLINKY_DIR: &str = "../dependencies/slinky/"; +/// Directory where the admin-module repo is located +const ADMIN_MODULE_DIR: &str = "../dependencies/admin-module/"; /// A temporary directory for repos storing const TMP_REPOS_DIR: &str = "./dependencies/"; @@ -82,6 +87,7 @@ pub fn generate() { git::clone_repo(ICS23_REPO, ICS23_DIR, ICS23_REV); git::clone_repo(FEEMARKET_REPO, FEEMARKET_DIR, FEEMARKET_REV); git::clone_repo(SLINKY_REPO, SLINKY_DIR, SLINKY_REV); + git::clone_repo(ADMIN_MODULE_REPO, ADMIN_MODULE_DIR, ADMIN_MODULE_REV); let tmp_build_dir: PathBuf = TMP_BUILD_DIR.parse().unwrap(); let out_dir: PathBuf = OUT_DIR.parse().unwrap(); @@ -142,6 +148,13 @@ pub fn generate() { exclude_mods: vec![], }; + let admin_project = CosmosProject { + name: "admin".to_string(), + version: ADMIN_MODULE_REV.to_string(), + project_dir: ADMIN_MODULE_DIR.to_string(), + exclude_mods: vec![], + }; + let neutron_code_generator = CodeGenerator::new( out_dir, tmp_build_dir, @@ -154,6 +167,7 @@ pub fn generate() { ics23_project, feemarket_project, slinky_project, + admin_project, ], );