Skip to content

Commit

Permalink
Merge pull request #160 from neutron-org/feat/unordered-ica
Browse files Browse the repository at this point in the history
feat: add possibility for unordered ica channels #ntrn-376
  • Loading branch information
pr0n00gler authored Sep 3, 2024
2 parents e0e697a + d99b7c2 commit 8ef5964
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 10 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
16 changes: 15 additions & 1 deletion packages/neutron-sdk/src/bindings/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 @@
v4.1.0
ba1b1d6dc91370d81e7125962e02aee01274eac
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 = "v4.1.0";
const NEUTRON_REV: &str = "ba1b1d6dc91370d81e7125962e02aee01274eac";

/// 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 8ef5964

Please sign in to comment.