From 5ba6368d20749c0aceff97cee4c8ab3d59b016a4 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Fri, 16 Apr 2021 10:24:13 +0200 Subject: [PATCH] Remover MEMBERS SnapshotMap --- contracts/cw4-group/src/contract.rs | 6 +++--- contracts/cw4-group/src/state.rs | 9 +-------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/contracts/cw4-group/src/contract.rs b/contracts/cw4-group/src/contract.rs index 5dcdf863d..d6abf06c2 100644 --- a/contracts/cw4-group/src/contract.rs +++ b/contracts/cw4-group/src/contract.rs @@ -13,7 +13,7 @@ use cw_storage_plus::Bound; use crate::error::ContractError; use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; -use crate::state::{members, ADMIN, HOOKS, MEMBERS, TOTAL}; +use crate::state::{members, ADMIN, HOOKS, TOTAL}; // version info for migration info const CONTRACT_NAME: &str = "crates.io:cw4-group"; @@ -176,7 +176,7 @@ fn query_total_weight(deps: Deps) -> StdResult { fn query_member(deps: Deps, addr: String, height: Option) -> StdResult { let addr = deps.api.addr_validate(&addr)?; let weight = match height { - Some(h) => MEMBERS.may_load_at_height(deps.storage, &addr, h), + Some(h) => members().primary.may_load_at_height(deps.storage, &addr, h), None => members().may_load(deps.storage, &addr), }?; Ok(MemberResponse { weight }) @@ -195,7 +195,7 @@ fn list_members( let addr = maybe_addr(deps.api, start_after)?; let start = addr.map(|addr| Bound::exclusive(addr.to_string())); - let members: StdResult> = MEMBERS + let members: StdResult> = members() .range(deps.storage, start, None, Order::Ascending) .take(limit) .map(|item| { diff --git a/contracts/cw4-group/src/state.rs b/contracts/cw4-group/src/state.rs index 5f23270f5..50d138017 100644 --- a/contracts/cw4-group/src/state.rs +++ b/contracts/cw4-group/src/state.rs @@ -2,7 +2,7 @@ use cosmwasm_std::Addr; use cw4::TOTAL_KEY; use cw_controllers::{Admin, Hooks}; use cw_storage_plus::{ - Index, IndexList, IndexedSnapshotMap, Item, MultiIndex, PkOwned, SnapshotMap, Strategy, U64Key, + Index, IndexList, IndexedSnapshotMap, Item, MultiIndex, PkOwned, Strategy, U64Key, }; pub const ADMIN: Admin = Admin::new("admin"); @@ -10,13 +10,6 @@ pub const HOOKS: Hooks = Hooks::new("cw4-hooks"); pub const TOTAL: Item = Item::new(TOTAL_KEY); -pub const MEMBERS: SnapshotMap<&Addr, u64> = SnapshotMap::new( - cw4::MEMBERS_KEY, - cw4::MEMBERS_CHECKPOINTS, - cw4::MEMBERS_CHANGELOG, - Strategy::EveryBlock, -); - pub struct MemberIndexes<'a> { // pk goes to second tuple element pub weight: MultiIndex<'a, (U64Key, PkOwned), u64>,