-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pool-manager): allow updating config
- Loading branch information
1 parent
62a82ed
commit 7d29f3c
Showing
8 changed files
with
273 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
pub mod commands; | ||
|
||
mod update_config; | ||
pub use update_config::update_config; |
42 changes: 42 additions & 0 deletions
42
contracts/liquidity_hub/pool-manager/src/manager/update_config.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use cosmwasm_std::{Coin, DepsMut, MessageInfo, Response}; | ||
use white_whale_std::pool_network::pair::FeatureToggle; | ||
|
||
use crate::{state::MANAGER_CONFIG, ContractError}; | ||
|
||
pub fn update_config( | ||
deps: DepsMut, | ||
info: MessageInfo, | ||
owner_addr: Option<String>, | ||
whale_lair_addr: Option<String>, | ||
pool_creation_fee: Option<Coin>, | ||
feature_toggle: Option<FeatureToggle>, | ||
) -> Result<Response, ContractError> { | ||
MANAGER_CONFIG.update(deps.storage, |mut config| { | ||
// permission check | ||
if info.sender != config.owner { | ||
return Err(ContractError::Unauthorized {}); | ||
} | ||
|
||
if let Some(owner) = owner_addr { | ||
let owner_addr = deps.api.addr_validate(&owner)?; | ||
config.owner = owner_addr; | ||
} | ||
|
||
if let Some(whale_lair_addr) = whale_lair_addr { | ||
let whale_lair_addr = deps.api.addr_validate(&whale_lair_addr)?; | ||
config.whale_lair_addr = whale_lair_addr; | ||
} | ||
|
||
if let Some(pool_creation_fee) = pool_creation_fee { | ||
config.pool_creation_fee = pool_creation_fee; | ||
} | ||
|
||
if let Some(feature_toggle) = feature_toggle { | ||
config.feature_toggle = feature_toggle; | ||
} | ||
|
||
Ok(config) | ||
})?; | ||
|
||
Ok(Response::new().add_attribute("action", "update_config")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.