From 29785255db777fec917225ec866d1c4be1d5512c Mon Sep 17 00:00:00 2001 From: swelf Date: Thu, 1 Aug 2024 17:25:41 +0300 Subject: [PATCH 1/3] removed hardcoded TOO_MANY_FILTER error --- packages/neutron-sdk/src/bindings/msg.rs | 39 ++++++------------- packages/neutron-sdk/src/errors/error.rs | 3 -- .../src/interchain_queries/types.rs | 1 - 3 files changed, 11 insertions(+), 32 deletions(-) diff --git a/packages/neutron-sdk/src/bindings/msg.rs b/packages/neutron-sdk/src/bindings/msg.rs index 5b8daf9c..04129e8e 100644 --- a/packages/neutron-sdk/src/bindings/msg.rs +++ b/packages/neutron-sdk/src/bindings/msg.rs @@ -1,8 +1,8 @@ use crate::{ bindings::types::{KVKey, ProtobufAny}, - interchain_queries::types::{QueryPayload, QueryType, TransactionFilterItem, MAX_TX_FILTERS}, + interchain_queries::types::{QueryPayload, QueryType, TransactionFilterItem}, sudo::msg::RequestPacketTimeoutHeight, - NeutronError, NeutronResult, + NeutronResult, }; use crate::bindings::dex::msg::DexMsg; @@ -295,22 +295,14 @@ impl NeutronMsg { connection_id, update_period, }, - QueryPayload::TX(transactions_filters) => { - if transactions_filters.len() > MAX_TX_FILTERS { - return Err(NeutronError::TooManyTransactionFilters { - max: MAX_TX_FILTERS, - }); - } else { - NeutronMsg::RegisterInterchainQuery { - query_type: QueryType::TX.into(), - keys: vec![], - transactions_filter: to_string(&transactions_filters) - .map_err(|e| StdError::generic_err(e.to_string()))?, - connection_id, - update_period, - } - } - } + QueryPayload::TX(transactions_filters) => NeutronMsg::RegisterInterchainQuery { + query_type: QueryType::TX.into(), + keys: vec![], + transactions_filter: to_string(&transactions_filters) + .map_err(|e| StdError::generic_err(e.to_string()))?, + connection_id, + update_period, + }, }) } @@ -330,16 +322,7 @@ impl NeutronMsg { new_update_period, new_transactions_filter: match new_transactions_filter { Some(filters) => { - if filters.len() > MAX_TX_FILTERS { - return Err(NeutronError::TooManyTransactionFilters { - max: MAX_TX_FILTERS, - }); - } else { - Some( - to_string(&filters) - .map_err(|e| StdError::generic_err(e.to_string()))?, - ) - } + Some(to_string(&filters).map_err(|e| StdError::generic_err(e.to_string()))?) } None => None, }, diff --git a/packages/neutron-sdk/src/errors/error.rs b/packages/neutron-sdk/src/errors/error.rs index 700f5224..c94ad5cb 100644 --- a/packages/neutron-sdk/src/errors/error.rs +++ b/packages/neutron-sdk/src/errors/error.rs @@ -48,9 +48,6 @@ pub enum NeutronError { #[error("Integration tests mock is active")] IntegrationTestsMock {}, - #[error("Too many transaction filters, max allowed: {max:?}")] - TooManyTransactionFilters { max: usize }, - #[error("Can't deconstruct account denom balance key: {0}")] AccountDenomBalanceKeyDeconstructionError(String), } diff --git a/packages/neutron-sdk/src/interchain_queries/types.rs b/packages/neutron-sdk/src/interchain_queries/types.rs index f3d164b2..4920ece6 100644 --- a/packages/neutron-sdk/src/interchain_queries/types.rs +++ b/packages/neutron-sdk/src/interchain_queries/types.rs @@ -59,7 +59,6 @@ impl Serialize for TransactionFilterValue { } } -pub const MAX_TX_FILTERS: usize = 32; #[derive(Serialize, Deserialize, Debug)] pub struct TransactionFilterItem { From a4844f4c31152bb7b94b5fe61a22cdc76594b37e Mon Sep 17 00:00:00 2001 From: swelf Date: Thu, 1 Aug 2024 17:43:19 +0300 Subject: [PATCH 2/3] fmt --- packages/neutron-sdk/src/interchain_queries/types.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/neutron-sdk/src/interchain_queries/types.rs b/packages/neutron-sdk/src/interchain_queries/types.rs index 4920ece6..d4a0c3f2 100644 --- a/packages/neutron-sdk/src/interchain_queries/types.rs +++ b/packages/neutron-sdk/src/interchain_queries/types.rs @@ -59,7 +59,6 @@ impl Serialize for TransactionFilterValue { } } - #[derive(Serialize, Deserialize, Debug)] pub struct TransactionFilterItem { pub field: String, From a5ca4483814ec2dc639cfc5ba1f52dcae040960d Mon Sep 17 00:00:00 2001 From: nhpd Date: Fri, 2 Aug 2024 03:09:26 +0400 Subject: [PATCH 3/3] feat: add burn_from_address arg to submit_burn_tokens method --- packages/neutron-sdk/src/bindings/msg.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/neutron-sdk/src/bindings/msg.rs b/packages/neutron-sdk/src/bindings/msg.rs index 5b8daf9c..0a11eded 100644 --- a/packages/neutron-sdk/src/bindings/msg.rs +++ b/packages/neutron-sdk/src/bindings/msg.rs @@ -432,11 +432,16 @@ impl NeutronMsg { /// Basic helper to define burn tokens passed to TokenFactory module: /// * **denom** is a name of the denom; /// * **amount** is an amount of tokens to burn. - pub fn submit_burn_tokens(denom: impl Into, amount: Uint128) -> Self { + /// * **burn_from_address** is an address tokens will be burned from + pub fn submit_burn_tokens( + denom: impl Into, + amount: Uint128, + burn_from_address: Option, + ) -> Self { NeutronMsg::BurnTokens { denom: denom.into(), amount, - burn_from_address: String::new(), + burn_from_address: burn_from_address.unwrap_or_default(), } }