Skip to content

Commit

Permalink
Fix MemberResponse / use From MemberInfo helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Mauro Lacy committed Feb 25, 2022
1 parent 4950d53 commit ca15a72
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
10 changes: 3 additions & 7 deletions contracts/tg4-engagement/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -759,15 +759,11 @@ fn query_member<Q: CustomQuery>(
height: Option<u64>,
) -> StdResult<MemberResponse> {
let addr = deps.api.addr_validate(&addr)?;
let points = match height {
let mi = match height {
Some(h) => members().may_load_at_height(deps.storage, &addr, h),
None => members().may_load(deps.storage, &addr),
}?
.map(|mi| mi.points);
Ok(MemberResponse {
points,
start_height: None,
})
}?;
Ok(mi.into())
}

pub fn query_withdrawable_rewards<Q: CustomQuery>(
Expand Down
7 changes: 1 addition & 6 deletions contracts/tg4-mixer/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,12 +426,7 @@ fn query_member<Q: CustomQuery>(
Some(h) => members().may_load_at_height(deps.storage, &addr, h),
None => members().may_load(deps.storage, &addr),
}?;
let points = mi.as_ref().map(|mi| mi.points);
let start_height = mi.map(|mi| mi.start_height).unwrap_or(None);
Ok(MemberResponse {
points,
start_height,
})
Ok(mi.into())
}

// settings for pagination
Expand Down
10 changes: 3 additions & 7 deletions contracts/tg4-stake/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,15 +522,11 @@ fn query_member<Q: CustomQuery>(
height: Option<u64>,
) -> StdResult<MemberResponse> {
let addr = deps.api.addr_validate(&addr)?;
let points = match height {
let mi = match height {
Some(h) => members().may_load_at_height(deps.storage, &addr, h),
None => members().may_load(deps.storage, &addr),
}?
.map(|mi| mi.points);
Ok(MemberResponse {
points,
start_height: None,
})
}?;
Ok(mi.into())
}

// settings for pagination
Expand Down

0 comments on commit ca15a72

Please sign in to comment.