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

chore: instantiate msg qol #233

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
6 changes: 4 additions & 2 deletions contract/src/consts.rs
Original file line number Diff line number Diff line change
@@ -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;
14 changes: 7 additions & 7 deletions contract/src/contract.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand Down Expand Up @@ -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)?;
Expand Down
8 changes: 5 additions & 3 deletions contract/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down