From fa144d9e49d0a7e48b4006bc4593f4a7735b6d48 Mon Sep 17 00:00:00 2001 From: nhpd Date: Wed, 11 Oct 2023 17:40:20 +0400 Subject: [PATCH] add timeouts as initialization msg parts to test them --- src/contract.rs | 12 ++++++++---- src/msg.rs | 6 ++++++ src/state.rs | 2 ++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/contract.rs b/src/contract.rs index 96bdd2d..11dc390 100644 --- a/src/contract.rs +++ b/src/contract.rs @@ -40,8 +40,6 @@ const MSG_FUND_COMMUNITY_POOL: &str = "/cosmos.distribution.v1beta1.MsgFundCommu const SEND_TO_ICA_MEMO: &str = "transfer unclaimed airdrop to Cosmos Hub"; const FUND_COMMUNITY_POOL_MEMO: &str = "fund community pool from neutron unclaimed airdrop"; -const TIMEOUT: u64 = 7200; // 2 hours - #[cfg_attr(not(feature = "library"), entry_point)] pub fn instantiate( deps: DepsMut, @@ -59,6 +57,8 @@ pub fn instantiate( airdrop_address: deps.api.addr_validate(&msg.airdrop_address)?, channel_id_to_hub: msg.channel_id_to_hub, ibc_neutron_denom: msg.ibc_neutron_denom, + transfer_timeout_seconds: msg.transfer_timeout_seconds, + ica_timeout_seconds: msg.ica_timeout_seconds, }, )?; INTERCHAIN_ACCOUNT.save(deps.storage, &None)?; @@ -182,7 +182,11 @@ fn execute_send_claimed_tokens_to_ica( revision_number: None, revision_height: None, }, - timeout_timestamp: env.block.time.plus_seconds(TIMEOUT).nanos(), + timeout_timestamp: env + .block + .time + .plus_seconds(config.transfer_timeout_seconds) + .nanos(), memo: SEND_TO_ICA_MEMO.to_string(), fee, }; @@ -241,7 +245,7 @@ fn execute_fund_community_pool( ICA_ID.to_string(), vec![any_msg], FUND_COMMUNITY_POOL_MEMO.to_string(), - TIMEOUT, + config.ica_timeout_seconds, fee, ); diff --git a/src/msg.rs b/src/msg.rs index 834aa96..7304147 100644 --- a/src/msg.rs +++ b/src/msg.rs @@ -13,6 +13,12 @@ pub struct InstantiateMsg { // IBC denom of neutron that was sent over our `cosmoshub_channel` pub ibc_neutron_denom: String, + + /// timeout for ibc transfer + pub transfer_timeout_seconds: u64, + + /// timeout for ica transactions + pub ica_timeout_seconds: u64, } #[cw_serde] diff --git a/src/state.rs b/src/state.rs index 6399e2c..a0a84d5 100644 --- a/src/state.rs +++ b/src/state.rs @@ -29,6 +29,8 @@ pub struct Config { pub airdrop_address: Addr, pub channel_id_to_hub: String, pub ibc_neutron_denom: String, + pub transfer_timeout_seconds: u64, + pub ica_timeout_seconds: u64, } #[cw_serde]