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: remove cron wasmbindings #ntrn-387 #163

Closed
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
62 changes: 15 additions & 47 deletions packages/neutron-sdk/src/bindings/msg.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::{
bindings::types::{KVKey, ProtobufAny},
interchain_queries::types::{QueryPayload, QueryType, TransactionFilterItem},
proto_types::neutron::cron::ExecutionStage,
sudo::msg::RequestPacketTimeoutHeight,
NeutronResult,
};
Expand All @@ -28,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 @@ -43,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 @@ -89,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 @@ -206,26 +216,6 @@ pub enum NeutronMsg {
uri_hash: String,
},

/// AddSchedule adds new schedule with a given `name`.
/// Until schedule is removed it will execute all `msgs` every `period` blocks.
/// First execution is at least on `current_block + period` block.
/// [Permissioned - DAO Only]
AddSchedule {
/// Name of a new schedule.
/// Needed to be able to `RemoveSchedule` and to log information about it
name: String,
/// period in blocks with which `msgs` will be executed
period: u64,
/// list of cosmwasm messages to be executed
msgs: Vec<MsgExecuteContract>,
/// execution stage where schedule will be executed
execution_stage: String,
},

/// RemoveSchedule removes the schedule with a given `name`.
/// [Permissioned - DAO or Security DAO only]
RemoveSchedule { name: String },

/// Contractmanager message
/// Resubmits failed acknowledgement.
/// Acknowledgement failure is created when contract returns error or acknowledgement is out of gas.
Expand All @@ -240,15 +230,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 @@ -496,31 +489,6 @@ impl NeutronMsg {
}
}

/// Basic helper to define add schedule passed to Cron module:
/// * **name** is a name of the schedule;
/// * **period** is a period of schedule execution in blocks;
/// * **msgs** is the messages that will be executed.
/// * **execution_stage** is the stage where schedule will be executed.
pub fn submit_add_schedule(
name: String,
period: u64,
msgs: Vec<MsgExecuteContract>,
execution_stage: ExecutionStage,
) -> Self {
NeutronMsg::AddSchedule {
name,
period,
msgs,
execution_stage: execution_stage.as_str_name().to_string(),
}
}

/// Basic helper to define remove schedule passed to Cron module:
/// * **name** is a name of the schedule to be removed.
pub fn submit_remove_schedule(name: String) -> Self {
NeutronMsg::RemoveSchedule { name }
}

/// Basic helper to define resubmit failure passed to Contractmanager module:
/// * **failure_id** is an id of the failure to be resubmitted.
pub fn submit_resubmit_failure(failure_id: u64) -> Self {
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
Loading