Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feat/add_simulateXXQu…
Browse files Browse the repository at this point in the history
…eries
  • Loading branch information
jcompagni10 committed Sep 3, 2024
2 parents a4e23fe + 8ef5964 commit 9fb4fbd
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 43 deletions.
17 changes: 10 additions & 7 deletions contracts/neutron_interchain_txs/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};
use neutron_sdk::bindings::msg::IbcFee;
use crate::storage::{
add_error_to_queue, read_errors_from_queue, read_reply_payload, read_sudo_payload,
save_reply_payload, save_sudo_payload, AcknowledgementResult, SudoPayload,
ACKNOWLEDGEMENT_RESULTS, INTERCHAIN_ACCOUNTS, SUDO_PAYLOAD_REPLY_ID,
};
use neutron_sdk::bindings::msg::{ChannelOrdering, IbcFee};
use neutron_sdk::proto_types::neutron::interchaintxs::v1::MsgSubmitTxResponse;
use neutron_sdk::{
bindings::{
Expand All @@ -27,12 +32,6 @@ use neutron_sdk::{
NeutronError, NeutronResult,
};

use crate::storage::{
add_error_to_queue, read_errors_from_queue, read_reply_payload, read_sudo_payload,
save_reply_payload, save_sudo_payload, AcknowledgementResult, SudoPayload,
ACKNOWLEDGEMENT_RESULTS, INTERCHAIN_ACCOUNTS, SUDO_PAYLOAD_REPLY_ID,
};

// Default timeout for SubmitTX is two weeks
const DEFAULT_TIMEOUT_SECONDS: u64 = 60 * 60 * 24 * 7 * 2;
const FEE_DENOM: &str = "untrn";
Expand Down Expand Up @@ -77,12 +76,14 @@ pub fn execute(
connection_id,
interchain_account_id,
register_fee,
ordering,
} => execute_register_ica(
deps,
env,
connection_id,
interchain_account_id,
register_fee,
ordering,
),
ExecuteMsg::Delegate {
validator,
Expand Down Expand Up @@ -198,11 +199,13 @@ fn execute_register_ica(
connection_id: String,
interchain_account_id: String,
register_fee: Vec<CoinSDK>,
ordering: Option<ChannelOrdering>,
) -> NeutronResult<Response<NeutronMsg>> {
let register = NeutronMsg::register_interchain_account(
connection_id,
interchain_account_id.clone(),
Some(register_fee),
ordering,
);
let key = get_port_id(env.contract.address.as_str(), &interchain_account_id);
// we are saving empty data here because we handle response of registering ICA in sudo_open_ack method
Expand Down
2 changes: 2 additions & 0 deletions contracts/neutron_interchain_txs/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use cosmwasm_std::Coin;
use neutron_sdk::bindings::msg::ChannelOrdering;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -36,6 +37,7 @@ pub enum ExecuteMsg {
connection_id: String,
interchain_account_id: String,
register_fee: Vec<Coin>,
ordering: Option<ChannelOrdering>,
},
Delegate {
interchain_account_id: String,
Expand Down
55 changes: 26 additions & 29 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 All @@ -27,6 +27,13 @@ pub struct IbcFee {
pub timeout_fee: Vec<Coin>,
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum ChannelOrdering {
OrderOrdered,
OrderUnordered,
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case")]
/// A number of Custom messages that can call into the Neutron bindings.
Expand All @@ -42,6 +49,10 @@ pub enum NeutronMsg {

/// **register_fee** is a fees required to be payed to register interchain account
register_fee: Option<Vec<Coin>>,

/// **ordering** is an order of channel. Can be ordered or unordered.
/// Set to ordered if not specified.
ordering: Option<ChannelOrdering>,
},

/// SubmitTx starts the process of executing any Cosmos-SDK *msgs* on remote chain.
Expand Down Expand Up @@ -88,7 +99,7 @@ pub enum NeutronMsg {
/// **query_id** is the ID of the query we want to update.
query_id: u64,

/// **new_keys** is the new query keys to retrive.
/// **new_keys** is the new query keys to retrieve.
new_keys: Option<Vec<KVKey>>,

/// **new_update_period** is a new update period of the query.
Expand Down Expand Up @@ -237,15 +248,18 @@ impl NeutronMsg {
/// Basic helper to define a register interchain account message:
/// * **connection_id** is an IBC connection identifier between Neutron and remote chain;
/// * **interchain_account_id** is an identifier of your new interchain account. Can be any string.
/// * **ordering** is an ordering of ICA channel. Set to ORDERED if not specified
pub fn register_interchain_account(
connection_id: String,
interchain_account_id: String,
register_fee: Option<Vec<Coin>>,
ordering: Option<ChannelOrdering>,
) -> Self {
NeutronMsg::RegisterInterchainAccount {
connection_id,
interchain_account_id,
register_fee,
ordering,
}
}

Expand Down Expand Up @@ -295,22 +309,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 +336,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
2 changes: 1 addition & 1 deletion packages/neutron-sdk/src/proto_types/NEUTRON_COMMIT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f0fe2f9adfd5ff6c092d50c6a30adb4efab8a590
d557574271951b6e0fd3c7467e0a2981e068b826
14 changes: 14 additions & 0 deletions packages/neutron-sdk/src/proto_types/neutron/interchainqueries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,15 @@ pub struct MsgRegisterInterchainAccount {
pub interchain_account_id: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "4")]
pub register_fee: ::prost::alloc::vec::Vec<super::super::super::cosmos::base::v1beta1::Coin>,
#[prost(
enumeration = "super::super::super::ibc::core::channel::v1::Order",
tag = "5"
)]
#[serde(
serialize_with = "crate::serde::as_str::serialize",
deserialize_with = "crate::serde::as_str::deserialize"
)]
pub ordering: i32,
}
/// MsgRegisterInterchainAccountResponse is the response type for
/// MsgRegisterInterchainAccount.
Expand Down
2 changes: 1 addition & 1 deletion proto-build/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "f0fe2f9adfd5ff6c092d50c6a30adb4efab8a590";
const NEUTRON_REV: &str = "d557574271951b6e0fd3c7467e0a2981e068b826";

/// The wasmd commit or tag to be cloned and used to build the proto files
const WASMD_REV: &str = "v0.51.0";
Expand Down

0 comments on commit 9fb4fbd

Please sign in to comment.