Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add possibility for unordered ica channels #ntrn-376 #62

Merged
merged 9 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ incremental = false
overflow-checks = true

[workspace.dependencies]
neutron-sdk = { package = "neutron-sdk", git = "https://github.com/neutron-org/neutron-sdk", branch = "main" }
neutron-sdk = { package = "neutron-sdk", git = "https://github.com/neutron-org/neutron-sdk", branch = "feat/unordered-ica" }
prost = "0.12.4"
prost-types = "0.12.4"
cosmos-sdk-proto = { version = "0.20.0", default-features = false }
Expand Down
22 changes: 20 additions & 2 deletions contracts/neutron_interchain_txs/schema/execute_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@
},
"interchain_account_id": {
"type": "string"
},
"ordering": {
"anyOf": [
{
"$ref": "#/definitions/ChannelOrdering"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false
Expand Down Expand Up @@ -242,7 +252,7 @@
"additionalProperties": false
},
{
"description": "Used only in integration tests framework to simulate failures. After executing this message, any sudo call to the contract will result in an submessage processing error.",
"description": "Used only in integration tests framework to simulate failures. After executing this message, any sudo call to the contract will result in a submessage processing error.",
"type": "object",
"required": [
"integration_tests_set_sudo_submsg_failure_mock"
Expand All @@ -256,7 +266,7 @@
"additionalProperties": false
},
{
"description": "Used only in integration tests framework to simulate failures. After executing this message, any sudo call to the contract will result in an submessage reply processing error.",
"description": "Used only in integration tests framework to simulate failures. After executing this message, any sudo call to the contract will result in a submessage reply processing error.",
"type": "object",
"required": [
"integration_tests_set_sudo_submsg_reply_failure_mock"
Expand Down Expand Up @@ -299,6 +309,14 @@
}
],
"definitions": {
"ChannelOrdering": {
"type": "string",
"enum": [
"NONE",
"ORDER_ORDERED",
"ORDER_UNORDERED"
]
},
"IntegrationTestsSudoFailureMock": {
"type": "string",
"enum": [
Expand Down
7 changes: 5 additions & 2 deletions contracts/neutron_interchain_txs/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use crate::integration_tests_mock_handlers::{
use crate::msg::{
AcknowledgementResultsResponse, ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg,
};
use neutron_sdk::bindings::msg::{IbcFee, NeutronMsg};
use neutron_sdk::bindings::msg::{ChannelOrdering, IbcFee, NeutronMsg};
use neutron_sdk::bindings::query::{NeutronQuery, QueryInterchainAccountAddressResponse};
use neutron_sdk::bindings::types::ProtobufAny;
use neutron_sdk::interchain_txs::helpers::{decode_message_response, get_port_id};
Expand Down Expand Up @@ -108,7 +108,8 @@ pub fn execute(
ExecuteMsg::Register {
connection_id,
interchain_account_id,
} => execute_register_ica(deps, env, connection_id, interchain_account_id),
ordering,
} => execute_register_ica(deps, env, connection_id, interchain_account_id, ordering),
ExecuteMsg::Delegate {
validator,
interchain_account_id,
Expand Down Expand Up @@ -307,12 +308,14 @@ fn execute_register_ica(
env: Env,
connection_id: String,
interchain_account_id: String,
ordering: Option<ChannelOrdering>,
) -> StdResult<Response<NeutronMsg>> {
let register_fee = REGISTER_FEE.load(deps.storage)?;
let register = NeutronMsg::register_interchain_account(
connection_id,
interchain_account_id.clone(),
Option::from(register_fee),
ordering,
);
let key = get_port_id(env.contract.address.as_str(), &interchain_account_id);
INTERCHAIN_ACCOUNTS.save(deps.storage, key, &None)?;
Expand Down
6 changes: 4 additions & 2 deletions contracts/neutron_interchain_txs/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::storage::{AcknowledgementResult, IntegrationTestsSudoFailureMock};
use cosmwasm_std::Uint128;
use neutron_sdk::bindings::msg::ChannelOrdering;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -38,6 +39,7 @@ pub enum ExecuteMsg {
Register {
connection_id: String,
interchain_account_id: String,
ordering: Option<ChannelOrdering>,
},
SetFees {
denom: String,
Expand Down Expand Up @@ -76,11 +78,11 @@ pub enum ExecuteMsg {
state: IntegrationTestsSudoFailureMock,
},
/// Used only in integration tests framework to simulate failures.
/// After executing this message, any sudo call to the contract will result in an submessage
/// After executing this message, any sudo call to the contract will result in a submessage
/// processing error.
IntegrationTestsSetSudoSubmsgFailureMock {},
/// Used only in integration tests framework to simulate failures.
/// After executing this message, any sudo call to the contract will result in an submessage
/// After executing this message, any sudo call to the contract will result in a submessage
/// reply processing error.
IntegrationTestsSetSudoSubmsgReplyFailureMock {},
/// Used only in integration tests framework to simulate failures.
Expand Down
10 changes: 7 additions & 3 deletions contracts/neutron_validator_test/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};
use neutron_sdk::bindings::msg::{IbcFee, NeutronMsg};
use neutron_sdk::bindings::msg::{ChannelOrdering, IbcFee, NeutronMsg};
use neutron_sdk::bindings::query::{
NeutronQuery, QueryInterchainAccountAddressResponse, QueryRegisteredQueryResponse,
};
Expand Down Expand Up @@ -267,8 +267,12 @@ fn execute_register_ica(
connection_id: String,
interchain_account_id: String,
) -> NeutronResult<Response<NeutronMsg>> {
let register =
NeutronMsg::register_interchain_account(connection_id, interchain_account_id.clone(), None);
let register = NeutronMsg::register_interchain_account(
connection_id,
interchain_account_id.clone(),
None,
Some(ChannelOrdering::OrderOrdered),
);
let key = get_port_id(env.contract.address.as_str(), &interchain_account_id);
INTERCHAIN_ACCOUNTS.save(deps.storage, key, &None)?;
Ok(Response::new().add_message(register))
Expand Down
21 changes: 20 additions & 1 deletion contracts/reflect/schema/execute_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,14 @@
},
"additionalProperties": false
},
"ChannelOrdering": {
"type": "string",
"enum": [
"NONE",
"ORDER_ORDERED",
"ORDER_UNORDERED"
]
},
"ClearAdminProposal": {
"description": "Deprecated. SudoContractProposal defines the struct for clear admin proposal.",
"deprecated": true,
Expand Down Expand Up @@ -1338,6 +1346,17 @@
"description": "**interchain_account_id** is an identifier of your new interchain account. Can be any string. This identifier allows contracts to have multiple interchain accounts on remote chains.",
"type": "string"
},
"ordering": {
"description": "**ordering** is an order of channel. Can be ordered or unordered. Set to ordered if not specified.",
"anyOf": [
{
"$ref": "#/definitions/ChannelOrdering"
},
{
"type": "null"
}
]
},
"register_fee": {
"description": "*register_fee** is a fees required to be payed to register interchain account",
"type": [
Expand Down Expand Up @@ -1473,7 +1492,7 @@
],
"properties": {
"new_keys": {
"description": "*new_keys** is the new query keys to retrive.",
"description": "*new_keys** is the new query keys to retrieve.",
"type": [
"array",
"null"
Expand Down
9 changes: 8 additions & 1 deletion contracts/reflect/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,14 @@ pub fn query(deps: Deps<InterchainQueries>, env: Env, msg: QueryMsg) -> StdResul
pub fn reply(_deps: DepsMut, _env: Env, msg: Reply) -> StdResult<Response> {
match msg.id {
REFLECT_REPLY_ID => {
Ok(Response::default().set_data(msg.result.unwrap().msg_responses[0].clone().value))
let res = Response::default();

let msg_responses = msg.result.unwrap().msg_responses;
if msg_responses.is_empty() {
Ok(res)
} else {
Ok(res.set_data(msg_responses[0].clone().value))
}
}
_ => {
unimplemented!()
Expand Down
Loading