diff --git a/Cargo.lock b/Cargo.lock index 09b3da3..2713d8d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -933,7 +933,7 @@ dependencies = [ [[package]] name = "seda-common" version = "0.1.0" -source = "git+https://github.com/sedaprotocol/seda-common-rs.git?branch=main#eaea0a9bffd5ae192ead0dd9da2f91c21783b123" +source = "git+https://github.com/sedaprotocol/seda-common-rs.git?branch=chore/instantiate-qol#b1fe4f8dd5b602af713062f50a19c11e689aee0d" dependencies = [ "base64", "cosmwasm-schema", diff --git a/Cargo.toml b/Cargo.toml index f81e323..2addcb7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,7 @@ k256 = { version = "0.13", default-features = false, features = ["ecdsa"] } libfuzzer-sys = "0.4" rand = "0.8" schemars = { version = "0.8", features = ["semver"] } -seda-common = { git = "https://github.com/sedaprotocol/seda-common-rs.git", branch = "main" } +seda-common = { git = "https://github.com/sedaprotocol/seda-common-rs.git", branch = "chore/instantiate-qol" } # leaving this in to make local development easier # seda-common = { path = "../seda-common-rs/crates/common" } semver = { version = "1.0", features = ["serde"] } diff --git a/contract/src/consts.rs b/contract/src/consts.rs index 5c57427..f4b4691 100644 --- a/contract/src/consts.rs +++ b/contract/src/consts.rs @@ -1,5 +1,7 @@ -pub const INITIAL_MINIMUM_STAKE_TO_REGISTER: u128 = 1; -pub const INITIAL_MINIMUM_STAKE_FOR_COMMITTEE_ELIGIBILITY: u128 = 1; +use cosmwasm_std::Uint128; + +pub const INITIAL_MINIMUM_STAKE_TO_REGISTER: Uint128 = Uint128::new(1); +pub const INITIAL_MINIMUM_STAKE_FOR_COMMITTEE_ELIGIBILITY: Uint128 = Uint128::new(1); pub const INITIAL_COMMIT_TIMEOUT_IN_BLOCKS: u64 = 10; pub const INITIAL_REVEAL_TIMEOUT_IN_BLOCKS: u64 = 10; diff --git a/contract/src/contract.rs b/contract/src/contract.rs index 3090cf1..414261d 100644 --- a/contract/src/contract.rs +++ b/contract/src/contract.rs @@ -1,6 +1,6 @@ +use cosmwasm_std::Event; #[cfg(not(feature = "library"))] use cosmwasm_std::{entry_point, Binary, Deps, DepsMut, Env, MessageInfo, Response}; -use cosmwasm_std::{Event, Uint128}; use cw2::set_contract_version; use data_requests::TimeoutConfig; use seda_common::msgs::*; @@ -46,17 +46,17 @@ pub fn instantiate( CHAIN_ID.save(deps.storage, &msg.chain_id)?; PENDING_OWNER.save(deps.storage, &None)?; - let init_staking_config = StakingConfig { - minimum_stake_to_register: Uint128::new(INITIAL_MINIMUM_STAKE_TO_REGISTER), - minimum_stake_for_committee_eligibility: Uint128::new(INITIAL_MINIMUM_STAKE_FOR_COMMITTEE_ELIGIBILITY), + let init_staking_config = msg.staking_config.unwrap_or(StakingConfig { + minimum_stake_to_register: INITIAL_MINIMUM_STAKE_TO_REGISTER, + minimum_stake_for_committee_eligibility: INITIAL_MINIMUM_STAKE_FOR_COMMITTEE_ELIGIBILITY, allowlist_enabled: false, - }; + }); STAKING_CONFIG.save(deps.storage, &init_staking_config)?; - let init_timeout_config = TimeoutConfig { + let init_timeout_config = msg.timeout_config.unwrap_or(TimeoutConfig { commit_timeout_in_blocks: INITIAL_COMMIT_TIMEOUT_IN_BLOCKS, reveal_timeout_in_blocks: INITIAL_REVEAL_TIMEOUT_IN_BLOCKS, - }; + }); TIMEOUT_CONFIG.save(deps.storage, &init_timeout_config)?; STAKERS.initialize(deps.storage)?; diff --git a/contract/src/test_utils.rs b/contract/src/test_utils.rs index 4262774..f4f503e 100644 --- a/contract/src/test_utils.rs +++ b/contract/src/test_utils.rs @@ -53,9 +53,11 @@ impl TestInfo { let code_id = app.store_code_with_creator(creator.addr(), contract); let init_msg = to_json_binary(&InstantiateMsg { - token: "aseda".to_string(), - owner: creator.addr().into_string(), - chain_id: chain_id.clone(), + token: "aseda".to_string(), + owner: creator.addr().into_string(), + chain_id: chain_id.clone(), + staking_config: None, + timeout_config: None, }) .unwrap();