Skip to content

Commit

Permalink
Merge pull request #112 from neutron-org/feat/ica-register-fee
Browse files Browse the repository at this point in the history
added register_fee field for register interchain account msg
  • Loading branch information
pr0n00gler authored Sep 19, 2023
2 parents 51c5d33 + 8f88658 commit 82eb7e8
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 267 deletions.
32 changes: 30 additions & 2 deletions contracts/neutron_interchain_txs/schema/execute_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,21 @@
"type": "object",
"required": [
"connection_id",
"interchain_account_id"
"interchain_account_id",
"register_fee"
],
"properties": {
"connection_id": {
"type": "string"
},
"interchain_account_id": {
"type": "string"
},
"register_fee": {
"type": "array",
"items": {
"$ref": "#/definitions/Coin"
}
}
}
}
Expand Down Expand Up @@ -110,5 +117,26 @@
},
"additionalProperties": false
}
]
],
"definitions": {
"Coin": {
"type": "object",
"required": [
"amount",
"denom"
],
"properties": {
"amount": {
"$ref": "#/definitions/Uint128"
},
"denom": {
"type": "string"
}
}
},
"Uint128": {
"description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```",
"type": "string"
}
}
}
21 changes: 16 additions & 5 deletions contracts/neutron_interchain_txs/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use cosmos_sdk_proto::cosmos::staking::v1beta1::{
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
to_binary, Binary, CosmosMsg, CustomQuery, Deps, DepsMut, Env, MessageInfo, Reply, Response,
StdError, StdResult, SubMsg,
to_binary, Binary, Coin as CoinSDK, CosmosMsg, CustomQuery, Deps, DepsMut, Env, MessageInfo,
Reply, Response, StdError, StdResult, SubMsg,
};
use cw2::set_contract_version;
use prost::Message;
Expand Down Expand Up @@ -78,7 +78,14 @@ pub fn execute(
ExecuteMsg::Register {
connection_id,
interchain_account_id,
} => execute_register_ica(deps, env, connection_id, interchain_account_id),
register_fee,
} => execute_register_ica(
deps,
env,
connection_id,
interchain_account_id,
register_fee,
),
ExecuteMsg::Delegate {
validator,
interchain_account_id,
Expand Down Expand Up @@ -188,9 +195,13 @@ fn execute_register_ica(
env: Env,
connection_id: String,
interchain_account_id: String,
register_fee: Vec<CoinSDK>,
) -> NeutronResult<Response<NeutronMsg>> {
let register =
NeutronMsg::register_interchain_account(connection_id, interchain_account_id.clone());
let register = NeutronMsg::register_interchain_account(
connection_id,
interchain_account_id.clone(),
register_fee,
);
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
INTERCHAIN_ACCOUNTS.save(deps.storage, key, &None)?;
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,3 +1,4 @@
use cosmwasm_std::Coin;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -34,6 +35,7 @@ pub enum ExecuteMsg {
Register {
connection_id: String,
interchain_account_id: String,
register_fee: Vec<Coin>,
},
Delegate {
interchain_account_id: String,
Expand Down
Loading

0 comments on commit 82eb7e8

Please sign in to comment.