Skip to content

Commit

Permalink
removing extraneous iterator method for now and some other linter cha…
Browse files Browse the repository at this point in the history
…nges.
  • Loading branch information
arnabmitra committed Aug 14, 2023
1 parent decbd32 commit dce00f0
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 38 deletions.
2 changes: 1 addition & 1 deletion crates/contract/src/core/collateral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl LoanPoolMarkerCollateral {
marker_address,
marker_denom: marker_denom.into(),
share_count: Uint128::new(share_count),
removed_permissions: removed_permissions.to_owned(),
removed_permissions,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/contract/src/execute/settlement/add_loan_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub fn handle(
.iter()
.any(|event| event.ty == "loan_pool_added")
{
response = response.add_attribute("added_by", info.sender.clone());
response = response.add_attribute("added_by", info.sender);
}
// Set response data to collaterals vector
response = response.set_data(to_binary(&LoanPoolMarkers::new(collaterals))?);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::core::error::ContractError;
use crate::execute::settlement::extensions::ResultExtensions;
use crate::util::provenance_utilities::{
get_single_marker_coin_holding, marker_has_admin, marker_has_permissions, query_total_supply,
get_single_marker_coin_holding, marker_has_admin, marker_has_permissions,
};
use cosmwasm_std::{Addr, Uint128};
use provwasm_std::{Marker, MarkerAccess, MarkerStatus};
Expand Down
18 changes: 5 additions & 13 deletions crates/contract/src/execute/settlement/withdraw_loan_pool.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
use cosmwasm_std::{
to_binary, Addr, CosmosMsg, DepsMut, Env, Event, MessageInfo, Response, Storage,
};
use provwasm_std::{
grant_marker_access, revoke_marker_access, AccessGrant, Marker, MarkerAccess, ProvenanceMsg,
ProvenanceQuerier, ProvenanceQuery,
};
use cosmwasm_std::{to_binary, Addr, DepsMut, Env, Event, MessageInfo, Response};
use provwasm_std::{ProvenanceQuerier, ProvenanceQuery};

use crate::core::collateral::{LoanPoolMarkerCollateral, LoanPoolMarkers, LoanPoolRemovalData};
use crate::core::collateral::{LoanPoolMarkers, LoanPoolRemovalData};
use crate::core::security::WithdrawLoanPools;
use crate::execute::settlement::extensions::ResultExtensions;
use crate::storage::loan_pool_collateral::{get, remove};
use crate::util::provenance_utilities::release_marker_from_contract;
use crate::{
Expand Down Expand Up @@ -48,8 +42,7 @@ pub fn handle(
.map_err(|_| ContractError::InvalidAddress {
message: pool.clone(),
})?;
let removal_data =
withdraw_marker_pool_collateral(&deps, &info, &env, address.to_owned())?;
let removal_data = withdraw_marker_pool_collateral(&deps, &env, address.to_owned())?;
Ok((address, removal_data))
})
.collect::<Result<_, ContractError>>()?;
Expand Down Expand Up @@ -89,7 +82,6 @@ pub fn handle(

fn withdraw_marker_pool_collateral(
deps: &DepsMut<ProvenanceQuery>,
info: &MessageInfo,
env: &Env,
marker_address: Addr,
) -> Result<LoanPoolRemovalData, ContractError> {
Expand All @@ -98,7 +90,7 @@ fn withdraw_marker_pool_collateral(
ProvenanceQuerier::new(&deps.querier).get_marker_by_address(marker_address.clone())?;
let collateral = get(deps.storage, marker_address.clone())?;
let messages = release_marker_from_contract(
&marker.denom,
marker.denom,
&env.contract.address,
&collateral.removed_permissions,
)?;
Expand Down
19 changes: 0 additions & 19 deletions crates/contract/src/storage/loan_pool_collateral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,6 @@ pub fn get_with_state(
collateral
}

#[cfg(feature = "iterator")]
pub fn get_all_collaterals(
store: &dyn Storage,
) -> StdResult<Vec<(Addr, LoanPoolMarkerCollateral)>> {
let iter = COLLATERAL
.no_prefix_raw()
.range(store, None, None, Order::Ascending);

let items: Vec<(Addr, LoanPoolMarkerCollateral)> = iter
.map(|item| {
let (addr_bytes, collateral) = item.unwrap();
let addr = Addr::from(addr_bytes);
(addr, collateral)
})
.collect();

Ok(items)
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
5 changes: 2 additions & 3 deletions crates/contract/src/util/provenance_utilities.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use crate::core::error::ContractError;
use crate::execute::settlement::extensions::ResultExtensions;
use cosmwasm_std::{
coin, Addr, BankQuery, Coin, CosmosMsg, Deps, DepsMut, Empty, QuerierWrapper, StdResult,
SupplyResponse, Uint128,
coin, Addr, BankQuery, Coin, CosmosMsg, DepsMut, StdResult, SupplyResponse, Uint128,
};
use provwasm_std::{
grant_marker_access, revoke_marker_access, AccessGrant, Marker, MarkerAccess, ProvenanceMsg,
ProvenanceMsgParams, ProvenanceQuery,
ProvenanceQuery,
};

pub const NHASH: &str = "nhash";
Expand Down

0 comments on commit dce00f0

Please sign in to comment.