From 57e76c6d5e37ea124382fe2504fd55bb522189e3 Mon Sep 17 00:00:00 2001 From: pr0n00gler Date: Wed, 4 Sep 2024 16:32:31 +0300 Subject: [PATCH] bring it back --- packages/neutron-sdk/src/bindings/msg.rs | 18 +- .../src/proto_types/NEUTRON_COMMIT | 2 +- .../neutron/{cron.rs => cron/mod.rs} | 155 ++++++++++++++++-- .../src/proto_types/neutron/cron/v1.rs | 79 +++++++++ .../proto_types/neutron/interchainqueries.rs | 16 ++ proto-build/src/main.rs | 2 +- 6 files changed, 257 insertions(+), 15 deletions(-) rename packages/neutron-sdk/src/proto_types/neutron/{cron.rs => cron/mod.rs} (60%) create mode 100644 packages/neutron-sdk/src/proto_types/neutron/cron/v1.rs diff --git a/packages/neutron-sdk/src/bindings/msg.rs b/packages/neutron-sdk/src/bindings/msg.rs index 05acb208..cc2c3fed 100644 --- a/packages/neutron-sdk/src/bindings/msg.rs +++ b/packages/neutron-sdk/src/bindings/msg.rs @@ -1,6 +1,7 @@ use crate::{ bindings::types::{KVKey, ProtobufAny}, interchain_queries::types::{QueryPayload, QueryType, TransactionFilterItem}, + proto_types::neutron::cron::ExecutionStage, sudo::msg::RequestPacketTimeoutHeight, NeutronResult, }; @@ -228,6 +229,8 @@ pub enum NeutronMsg { period: u64, /// list of cosmwasm messages to be executed msgs: Vec, + /// execution stage where schedule will be executed + execution_stage: String, }, /// RemoveSchedule removes the schedule with a given `name`. @@ -511,8 +514,19 @@ impl NeutronMsg { /// * **name** is a name of the schedule; /// * **period** is a period of schedule execution in blocks; /// * **msgs** is the messages that will be executed. - pub fn submit_add_schedule(name: String, period: u64, msgs: Vec) -> Self { - NeutronMsg::AddSchedule { name, period, msgs } + /// * **execution_stage** is the stage where schedule will be executed. + pub fn submit_add_schedule( + name: String, + period: u64, + msgs: Vec, + execution_stage: ExecutionStage, + ) -> Self { + NeutronMsg::AddSchedule { + name, + period, + msgs, + execution_stage: execution_stage.as_str_name().to_string(), + } } /// Basic helper to define remove schedule passed to Cron module: diff --git a/packages/neutron-sdk/src/proto_types/NEUTRON_COMMIT b/packages/neutron-sdk/src/proto_types/NEUTRON_COMMIT index 007a1cae..f045e753 100644 --- a/packages/neutron-sdk/src/proto_types/NEUTRON_COMMIT +++ b/packages/neutron-sdk/src/proto_types/NEUTRON_COMMIT @@ -1 +1 @@ -ba1b1d6dc91370d81e7125962e02aee01274eac \ No newline at end of file +93ca90d30a0c4f75af0d30f52cd9abdf8018a715 \ No newline at end of file diff --git a/packages/neutron-sdk/src/proto_types/neutron/cron.rs b/packages/neutron-sdk/src/proto_types/neutron/cron/mod.rs similarity index 60% rename from packages/neutron-sdk/src/proto_types/neutron/cron.rs rename to packages/neutron-sdk/src/proto_types/neutron/cron/mod.rs index 8afa0a3f..f22c6ab9 100644 --- a/packages/neutron-sdk/src/proto_types/neutron/cron.rs +++ b/packages/neutron-sdk/src/proto_types/neutron/cron/mod.rs @@ -1,5 +1,6 @@ +pub mod v1; use neutron_std_derive::CosmwasmExt; -/// Params defines the parameters for the module. +/// Defines the parameters for the module. #[allow(clippy::derive_partial_eq_without_eq)] #[derive( Clone, @@ -24,6 +25,7 @@ pub struct Params { )] pub limit: u64, } +/// Defines the schedule for execution #[allow(clippy::derive_partial_eq_without_eq)] #[derive( Clone, @@ -47,7 +49,7 @@ pub struct Schedule { deserialize_with = "crate::serde::as_str::deserialize" )] pub period: u64, - /// Msgs that will be executed every period amount of time + /// Msgs that will be executed every certain number of blocks, specified in the `period` field #[prost(message, repeated, tag = "3")] pub msgs: ::prost::alloc::vec::Vec, /// Last execution's block height @@ -57,7 +59,15 @@ pub struct Schedule { deserialize_with = "crate::serde::as_str::deserialize" )] pub last_execute_height: u64, + /// Stage when messages will be executed + #[prost(enumeration = "ExecutionStage", tag = "5")] + #[serde( + serialize_with = "crate::serde::as_str::serialize", + deserialize_with = "crate::serde::as_str::deserialize" + )] + pub execution_stage: i32, } +/// Defines the contract and the message to pass #[allow(clippy::derive_partial_eq_without_eq)] #[derive( Clone, @@ -71,13 +81,14 @@ pub struct Schedule { )] #[proto_message(type_url = "/neutron.cron.MsgExecuteContract")] pub struct MsgExecuteContract { - /// Contract is the address of the smart contract + /// The address of the smart contract #[prost(string, tag = "1")] pub contract: ::prost::alloc::string::String, - /// Msg is json encoded message to be passed to the contract + /// JSON encoded message to be passed to the contract #[prost(string, tag = "2")] pub msg: ::prost::alloc::string::String, } +/// Defines the number of current schedules #[allow(clippy::derive_partial_eq_without_eq)] #[derive( Clone, @@ -91,7 +102,7 @@ pub struct MsgExecuteContract { )] #[proto_message(type_url = "/neutron.cron.ScheduleCount")] pub struct ScheduleCount { - /// Count is the number of current schedules + /// The number of current schedules #[prost(int32, tag = "1")] #[serde( serialize_with = "crate::serde::as_str::serialize", @@ -99,7 +110,37 @@ pub struct ScheduleCount { )] pub count: i32, } -/// GenesisState defines the cron module's genesis state. +/// Defines when messages will be executed in the block +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +#[derive(::serde::Serialize, ::serde::Deserialize, ::schemars::JsonSchema)] +pub enum ExecutionStage { + /// Execution at the end of the block + EndBlocker = 0, + /// Execution at the beginning of the block + BeginBlocker = 1, +} +impl ExecutionStage { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + ExecutionStage::EndBlocker => "EXECUTION_STAGE_END_BLOCKER", + ExecutionStage::BeginBlocker => "EXECUTION_STAGE_BEGIN_BLOCKER", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "EXECUTION_STAGE_END_BLOCKER" => Some(Self::EndBlocker), + "EXECUTION_STAGE_BEGIN_BLOCKER" => Some(Self::BeginBlocker), + _ => None, + } + } +} +/// Defines the cron module's genesis state. #[allow(clippy::derive_partial_eq_without_eq)] #[derive( Clone, @@ -119,6 +160,7 @@ pub struct GenesisState { #[prost(message, optional, tag = "1")] pub params: ::core::option::Option, } +/// The request type for the Query/Params RPC method. #[allow(clippy::derive_partial_eq_without_eq)] #[derive( Clone, @@ -133,6 +175,7 @@ pub struct GenesisState { #[proto_message(type_url = "/neutron.cron.QueryParamsRequest")] #[proto_query(path = "/neutron.cron.Query/Params", response_type = QueryParamsResponse)] pub struct QueryParamsRequest {} +/// The response type for the Query/Params RPC method. #[allow(clippy::derive_partial_eq_without_eq)] #[derive( Clone, @@ -150,6 +193,7 @@ pub struct QueryParamsResponse { #[prost(message, optional, tag = "1")] pub params: ::core::option::Option, } +/// The request type for the Query/Schedule RPC method. #[allow(clippy::derive_partial_eq_without_eq)] #[derive( Clone, @@ -170,6 +214,7 @@ pub struct QueryGetScheduleRequest { #[prost(string, tag = "1")] pub name: ::prost::alloc::string::String, } +/// The response type for the Query/Params RPC method. #[allow(clippy::derive_partial_eq_without_eq)] #[derive( Clone, @@ -186,6 +231,7 @@ pub struct QueryGetScheduleResponse { #[prost(message, optional, tag = "1")] pub schedule: ::core::option::Option, } +/// The request type for the Query/Schedules RPC method. #[allow(clippy::derive_partial_eq_without_eq)] #[derive( Clone, @@ -206,6 +252,7 @@ pub struct QuerySchedulesRequest { #[prost(message, optional, tag = "1")] pub pagination: ::core::option::Option, } +/// The response type for the Query/Params RPC method. #[allow(clippy::derive_partial_eq_without_eq)] #[derive( Clone, @@ -225,7 +272,94 @@ pub struct QuerySchedulesResponse { pub pagination: ::core::option::Option, } -/// MsgUpdateParams is the MsgUpdateParams request type. +/// The MsgAddSchedule request 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 = "/neutron.cron.MsgAddSchedule")] +pub struct MsgAddSchedule { + /// The address of the governance account. + #[prost(string, tag = "1")] + pub authority: ::prost::alloc::string::String, + /// Name of the schedule + #[prost(string, tag = "2")] + pub name: ::prost::alloc::string::String, + /// Period in blocks + #[prost(uint64, tag = "3")] + #[serde( + serialize_with = "crate::serde::as_str::serialize", + deserialize_with = "crate::serde::as_str::deserialize" + )] + pub period: u64, + /// Msgs that will be executed every certain number of blocks, specified in the `period` field + #[prost(message, repeated, tag = "4")] + pub msgs: ::prost::alloc::vec::Vec, + /// Stage when messages will be executed + #[prost(enumeration = "ExecutionStage", tag = "5")] + #[serde( + serialize_with = "crate::serde::as_str::serialize", + deserialize_with = "crate::serde::as_str::deserialize" + )] + pub execution_stage: i32, +} +/// Defines the response structure for executing a MsgAddSchedule message. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive( + Clone, + PartialEq, + Eq, + ::prost::Message, + ::serde::Serialize, + ::serde::Deserialize, + ::schemars::JsonSchema, + CosmwasmExt, +)] +#[proto_message(type_url = "/neutron.cron.MsgAddScheduleResponse")] +pub struct MsgAddScheduleResponse {} +/// The MsgRemoveSchedule request 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 = "/neutron.cron.MsgRemoveSchedule")] +pub struct MsgRemoveSchedule { + /// The address of the governance account. + #[prost(string, tag = "1")] + pub authority: ::prost::alloc::string::String, + /// Name of the schedule + #[prost(string, tag = "2")] + pub name: ::prost::alloc::string::String, +} +/// Defines the response structure for executing a MsgRemoveSchedule message. +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive( + Clone, + PartialEq, + Eq, + ::prost::Message, + ::serde::Serialize, + ::serde::Deserialize, + ::schemars::JsonSchema, + CosmwasmExt, +)] +#[proto_message(type_url = "/neutron.cron.MsgRemoveScheduleResponse")] +pub struct MsgRemoveScheduleResponse {} +/// The MsgUpdateParams request type. /// /// Since: 0.47 #[allow(clippy::derive_partial_eq_without_eq)] @@ -241,17 +375,16 @@ pub struct QuerySchedulesResponse { )] #[proto_message(type_url = "/neutron.cron.MsgUpdateParams")] pub struct MsgUpdateParams { - /// Authority is the address of the governance account. + /// The address of the governance account. #[prost(string, tag = "1")] pub authority: ::prost::alloc::string::String, - /// params defines the x/cron parameters to update. + /// Defines the x/cron parameters to update. /// /// NOTE: All parameters must be supplied. #[prost(message, optional, tag = "2")] pub params: ::core::option::Option, } -/// MsgUpdateParamsResponse defines the response structure for executing a -/// MsgUpdateParams message. +/// Defines the response structure for executing a MsgUpdateParams message. /// /// Since: 0.47 #[allow(clippy::derive_partial_eq_without_eq)] diff --git a/packages/neutron-sdk/src/proto_types/neutron/cron/v1.rs b/packages/neutron-sdk/src/proto_types/neutron/cron/v1.rs new file mode 100644 index 00000000..6776522a --- /dev/null +++ b/packages/neutron-sdk/src/proto_types/neutron/cron/v1.rs @@ -0,0 +1,79 @@ +use neutron_std_derive::CosmwasmExt; +/// Defines the schedule for execution +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive( + Clone, + PartialEq, + Eq, + ::prost::Message, + ::serde::Serialize, + ::serde::Deserialize, + ::schemars::JsonSchema, + CosmwasmExt, +)] +#[proto_message(type_url = "/neutron.cron.v1.Schedule")] +pub struct Schedule { + /// Name of schedule + #[prost(string, tag = "1")] + pub name: ::prost::alloc::string::String, + /// Period in blocks + #[prost(uint64, tag = "2")] + #[serde( + serialize_with = "crate::serde::as_str::serialize", + deserialize_with = "crate::serde::as_str::deserialize" + )] + pub period: u64, + /// Msgs that will be executed every certain number of blocks, specified in the `period` field + #[prost(message, repeated, tag = "3")] + pub msgs: ::prost::alloc::vec::Vec, + /// Last execution's block height + #[prost(uint64, tag = "4")] + #[serde( + serialize_with = "crate::serde::as_str::serialize", + deserialize_with = "crate::serde::as_str::deserialize" + )] + pub last_execute_height: u64, +} +/// Defines the contract and the message to pass +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive( + Clone, + PartialEq, + Eq, + ::prost::Message, + ::serde::Serialize, + ::serde::Deserialize, + ::schemars::JsonSchema, + CosmwasmExt, +)] +#[proto_message(type_url = "/neutron.cron.v1.MsgExecuteContract")] +pub struct MsgExecuteContract { + /// The address of the smart contract + #[prost(string, tag = "1")] + pub contract: ::prost::alloc::string::String, + /// JSON encoded message to be passed to the contract + #[prost(string, tag = "2")] + pub msg: ::prost::alloc::string::String, +} +/// Defines the number of current schedules +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive( + Clone, + PartialEq, + Eq, + ::prost::Message, + ::serde::Serialize, + ::serde::Deserialize, + ::schemars::JsonSchema, + CosmwasmExt, +)] +#[proto_message(type_url = "/neutron.cron.v1.ScheduleCount")] +pub struct ScheduleCount { + /// The number of current schedules + #[prost(int32, tag = "1")] + #[serde( + serialize_with = "crate::serde::as_str::serialize", + deserialize_with = "crate::serde::as_str::deserialize" + )] + pub count: i32, +} diff --git a/packages/neutron-sdk/src/proto_types/neutron/interchainqueries.rs b/packages/neutron-sdk/src/proto_types/neutron/interchainqueries.rs index 218970d1..bcd9487b 100644 --- a/packages/neutron-sdk/src/proto_types/neutron/interchainqueries.rs +++ b/packages/neutron-sdk/src/proto_types/neutron/interchainqueries.rs @@ -33,6 +33,20 @@ pub struct Params { deserialize_with = "crate::serde::as_str::deserialize" )] pub tx_query_removal_limit: u64, + /// Maximum amount of keys in a registered key value query + #[prost(uint64, tag = "4")] + #[serde( + serialize_with = "crate::serde::as_str::serialize", + deserialize_with = "crate::serde::as_str::deserialize" + )] + pub max_kv_query_keys_count: u64, + /// max_transactions_filters defines maximum allowed amount of tx filters in msgRegisterInterchainQuery + #[prost(uint64, tag = "5")] + #[serde( + serialize_with = "crate::serde::as_str::serialize", + deserialize_with = "crate::serde::as_str::deserialize" + )] + pub max_transactions_filters: u64, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive( @@ -234,6 +248,8 @@ pub struct MsgSubmitQueryResult { pub sender: ::prost::alloc::string::String, /// is the IBC client ID for an IBC connection between Neutron chain and target /// chain (where the result was obtained from) + /// Deprecated: populating this field does not make any affect + #[deprecated] #[prost(string, tag = "3")] #[serde(alias = "clientID")] pub client_id: ::prost::alloc::string::String, diff --git a/proto-build/src/main.rs b/proto-build/src/main.rs index aef0f71c..b1d9325a 100644 --- a/proto-build/src/main.rs +++ b/proto-build/src/main.rs @@ -23,7 +23,7 @@ const SLINKY_REPO: &str = "https://github.com/skip-mev/slinky.git"; const COSMOS_SDK_REV: &str = "v0.50.8-neutron"; /// The Neutron commit or tag to be cloned and used to build the proto files -const NEUTRON_REV: &str = "ba1b1d6dc91370d81e7125962e02aee01274eac"; +const NEUTRON_REV: &str = "93ca90d30a0c4f75af0d30f52cd9abdf8018a715"; /// The wasmd commit or tag to be cloned and used to build the proto files const WASMD_REV: &str = "v0.51.0";