-
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.
refactor: remove owner from Config since it's in ownable
- Loading branch information
Showing
10 changed files
with
25 additions
and
76 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
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
39 changes: 18 additions & 21 deletions
39
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 |
---|---|---|
@@ -1,42 +1,39 @@ | ||
use cosmwasm_std::{Coin, DepsMut, MessageInfo, Response}; | ||
use cosmwasm_std::{ensure, Coin, DepsMut, MessageInfo, Response}; | ||
use white_whale_std::pool_manager::Config; | ||
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> { | ||
let ownership = cw_ownable::get_ownership(deps.storage)?; | ||
|
||
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(owner) = ownership.owner { | ||
ensure!(owner == info.sender, ContractError::Unauthorized {}); | ||
|
||
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(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(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; | ||
if let Some(feature_toggle) = feature_toggle { | ||
config.feature_toggle = feature_toggle; | ||
} | ||
} | ||
|
||
Ok(config) | ||
Ok::<Config, ContractError>(config) | ||
})?; | ||
|
||
Ok(Response::new().add_attribute("action", "update_config")) | ||
Ok(Response::default().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
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