Skip to content

Commit

Permalink
Fix formatting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
MightOfOaks committed Jan 27, 2024
1 parent 9916e02 commit 06ef71a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 11 deletions.
56 changes: 46 additions & 10 deletions contracts/whitelist-updatable-flatrate/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use crate::state::{Config, CONFIG, TOTAL_ADDRESS_COUNT, WHITELIST};
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{to_json_binary, Addr, Binary, Deps, DepsMut, Empty, Env, Event, MessageInfo, Order, StdError, StdResult, ensure};
use cosmwasm_std::{
ensure, to_json_binary, Addr, Binary, Deps, DepsMut, Empty, Env, Event, MessageInfo, Order,
StdError, StdResult,
};
use cw2::set_contract_version;
use semver::Version;
use sg_name_minter::SgNameMinterQueryMsg;
Expand All @@ -27,7 +30,12 @@ pub fn instantiate(

let admin_list: Vec<Addr> = msg.admin_list.as_ref().map_or_else(
|| Ok(vec![info.sender.clone()]),
|admins| admins.iter().map(|addr| deps.api.addr_validate(addr)).collect(),
|admins| {
admins

Check warning on line 34 in contracts/whitelist-updatable-flatrate/src/contract.rs

View check run for this annotation

Codecov / codecov/patch

contracts/whitelist-updatable-flatrate/src/contract.rs#L34

Added line #L34 was not covered by tests
.iter()
.map(|addr| deps.api.addr_validate(addr))

Check warning on line 36 in contracts/whitelist-updatable-flatrate/src/contract.rs

View check run for this annotation

Codecov / codecov/patch

contracts/whitelist-updatable-flatrate/src/contract.rs#L36

Added line #L36 was not covered by tests
.collect()
},
)?;

let config = Config {
Expand Down Expand Up @@ -63,7 +71,9 @@ pub fn execute(
msg: ExecuteMsg,
) -> Result<Response, ContractError> {
match msg {
ExecuteMsg::UpdateAdmins { new_admin_list } => execute_update_admins(deps, info, new_admin_list),
ExecuteMsg::UpdateAdmins { new_admin_list } => {
execute_update_admins(deps, info, new_admin_list)
}
ExecuteMsg::AddAddresses { addresses } => execute_add_addresses(deps, info, addresses),
ExecuteMsg::RemoveAddresses { addresses } => {
execute_remove_addresses(deps, info, addresses)
Expand All @@ -83,7 +93,10 @@ pub fn execute_update_admins(
) -> Result<Response, ContractError> {
nonpayable(&info)?;
let mut config = CONFIG.load(deps.storage)?;
ensure!(config.admins.contains(&info.sender), ContractError::Unauthorized {});
ensure!(
config.admins.contains(&info.sender),
ContractError::Unauthorized {}

Check warning on line 98 in contracts/whitelist-updatable-flatrate/src/contract.rs

View check run for this annotation

Codecov / codecov/patch

contracts/whitelist-updatable-flatrate/src/contract.rs#L98

Added line #L98 was not covered by tests
);

config.admins = new_admin_list
.into_iter()
Expand All @@ -92,7 +105,14 @@ pub fn execute_update_admins(

CONFIG.save(deps.storage, &config)?;
let event = Event::new("update-admin")
.add_attribute("new_admin_list", config.admins.into_iter().map(|x| x.to_string()).collect::<String>())
.add_attribute(
"new_admin_list",
config
.admins
.into_iter()
.map(|x| x.to_string())
.collect::<String>(),
)
.add_attribute("sender", info.sender);
Ok(Response::new().add_event(event))
}
Expand All @@ -104,7 +124,10 @@ pub fn execute_add_addresses(
) -> Result<Response, ContractError> {
let config = CONFIG.load(deps.storage)?;
let mut count = TOTAL_ADDRESS_COUNT.load(deps.storage)?;
ensure!(config.admins.contains(&info.sender), ContractError::Unauthorized {});
ensure!(
config.admins.contains(&info.sender),
ContractError::Unauthorized {}

Check warning on line 129 in contracts/whitelist-updatable-flatrate/src/contract.rs

View check run for this annotation

Codecov / codecov/patch

contracts/whitelist-updatable-flatrate/src/contract.rs#L129

Added line #L129 was not covered by tests
);

// dedupe
addresses.sort_unstable();
Expand Down Expand Up @@ -138,7 +161,10 @@ pub fn execute_remove_addresses(
nonpayable(&info)?;
let config = CONFIG.load(deps.storage)?;
let mut count = TOTAL_ADDRESS_COUNT.load(deps.storage)?;
ensure!(config.admins.contains(&info.sender), ContractError::Unauthorized {});
ensure!(
config.admins.contains(&info.sender),
ContractError::Unauthorized {}

Check warning on line 166 in contracts/whitelist-updatable-flatrate/src/contract.rs

View check run for this annotation

Codecov / codecov/patch

contracts/whitelist-updatable-flatrate/src/contract.rs#L166

Added line #L166 was not covered by tests
);

// dedupe
addresses.sort_unstable();
Expand Down Expand Up @@ -209,7 +235,10 @@ pub fn execute_update_per_address_limit(
) -> Result<Response, ContractError> {
nonpayable(&info)?;
let mut config = CONFIG.load(deps.storage)?;
ensure!(config.admins.contains(&info.sender), ContractError::Unauthorized {});
ensure!(
config.admins.contains(&info.sender),
ContractError::Unauthorized {}

Check warning on line 240 in contracts/whitelist-updatable-flatrate/src/contract.rs

View check run for this annotation

Codecov / codecov/patch

contracts/whitelist-updatable-flatrate/src/contract.rs#L240

Added line #L240 was not covered by tests
);

config.per_address_limit = limit;
CONFIG.save(deps.storage, &config)?;
Expand All @@ -223,7 +252,10 @@ pub fn execute_update_per_address_limit(
pub fn execute_purge(deps: DepsMut, info: MessageInfo) -> Result<Response, ContractError> {
nonpayable(&info)?;
let config = CONFIG.load(deps.storage)?;
ensure!(config.admins.contains(&info.sender), ContractError::Unauthorized {});
ensure!(
config.admins.contains(&info.sender),
ContractError::Unauthorized {}

Check warning on line 257 in contracts/whitelist-updatable-flatrate/src/contract.rs

View check run for this annotation

Codecov / codecov/patch

contracts/whitelist-updatable-flatrate/src/contract.rs#L257

Added line #L257 was not covered by tests
);

let keys = WHITELIST
.keys(deps.as_ref().storage, None, None, Order::Ascending)
Expand Down Expand Up @@ -273,7 +305,11 @@ pub fn query_mint_count(deps: Deps, address: String) -> StdResult<u32> {

pub fn query_admins(deps: Deps) -> StdResult<String> {
let config = CONFIG.load(deps.storage)?;
Ok(config.admins.into_iter().map(|x| x.to_string()).collect::<String>())
Ok(config
.admins
.into_iter()
.map(|x| x.to_string())
.collect::<String>())
}

pub fn query_address_count(deps: Deps) -> StdResult<u64> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ mod tests {

#[test]
fn exec() {
let addrs= vec![
let addrs = vec![
"addr0001".to_string(),
"addr0002".to_string(),
"addr0003".to_string(),
Expand Down

0 comments on commit 06ef71a

Please sign in to comment.