Skip to content

Commit

Permalink
CW3: Add proposal_id field to VoteInfo structure
Browse files Browse the repository at this point in the history
  • Loading branch information
ueco-jb committed Feb 4, 2022
1 parent e45f038 commit bb4bac1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions contracts/cw3-fixed-multisig/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ fn query_vote(deps: Deps, proposal_id: u64, voter: String) -> StdResult<VoteResp
let voter = deps.api.addr_validate(&voter)?;
let ballot = BALLOTS.may_load(deps.storage, (proposal_id, &voter))?;
let vote = ballot.map(|b| VoteInfo {
proposal_id,
voter: voter.into(),
vote: b.vote,
weight: b.weight,
Expand All @@ -359,6 +360,7 @@ fn list_votes(
.take(limit)
.map(|item| {
item.map(|(addr, ballot)| VoteInfo {
proposal_id,
voter: addr.into(),
vote: ballot.vote,
weight: ballot.weight,
Expand Down
4 changes: 4 additions & 0 deletions contracts/cw3-flex-multisig/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ fn query_vote(deps: Deps, proposal_id: u64, voter: String) -> StdResult<VoteResp
let voter_addr = deps.api.addr_validate(&voter)?;
let prop = BALLOTS.may_load(deps.storage, (proposal_id, &voter_addr))?;
let vote = prop.map(|b| VoteInfo {
proposal_id,
voter,
vote: b.vote,
weight: b.weight,
Expand All @@ -388,6 +389,7 @@ fn list_votes(
.take(limit)
.map(|item| {
item.map(|(addr, ballot)| VoteInfo {
proposal_id,
voter: addr.into(),
vote: ballot.vote,
weight: ballot.weight,
Expand Down Expand Up @@ -1024,6 +1026,7 @@ mod tests {
assert_eq!(
vote.vote.unwrap(),
VoteInfo {
proposal_id,
voter: OWNER.into(),
vote: Vote::Yes,
weight: 0
Expand All @@ -1039,6 +1042,7 @@ mod tests {
assert_eq!(
vote.vote.unwrap(),
VoteInfo {
proposal_id,
voter: VOTER2.into(),
vote: Vote::No,
weight: 2
Expand Down
1 change: 1 addition & 0 deletions packages/cw3/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ pub struct VoteListResponse {
/// the address of the voter who submitted it
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
pub struct VoteInfo {
pub proposal_id: u64,
pub voter: String,
pub vote: Vote,
pub weight: u64,
Expand Down

0 comments on commit bb4bac1

Please sign in to comment.