Skip to content

Commit

Permalink
Merge pull request #158 from neutron-org/feat/icq-params-gov-gated
Browse files Browse the repository at this point in the history
feat: icq MaxKvQueryKeysCount and MaxTransactionsFilters gov gated #NTRN-364
  • Loading branch information
pr0n00gler authored Sep 2, 2024
2 parents a11018a + a47ca5f commit e0e697a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 33 deletions.
39 changes: 11 additions & 28 deletions packages/neutron-sdk/src/bindings/msg.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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,
},
})
}

Expand All @@ -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,
},
Expand Down
3 changes: 0 additions & 3 deletions packages/neutron-sdk/src/errors/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
2 changes: 0 additions & 2 deletions packages/neutron-sdk/src/interchain_queries/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ impl Serialize for TransactionFilterValue {
}
}

pub const MAX_TX_FILTERS: usize = 32;

#[derive(Serialize, Deserialize, Debug)]
pub struct TransactionFilterItem {
pub field: String,
Expand Down

0 comments on commit e0e697a

Please sign in to comment.