Skip to content

Commit

Permalink
add timeouts as initialization msg parts to test them
Browse files Browse the repository at this point in the history
  • Loading branch information
NeverHappened committed Oct 11, 2023
1 parent dd24f21 commit fa144d9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)?;
Expand Down Expand Up @@ -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,
};
Expand Down Expand Up @@ -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,
);

Expand Down
6 changes: 6 additions & 0 deletions src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 2 additions & 0 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit fa144d9

Please sign in to comment.