dao_migrator/utils/
query_helpers.rs1use cw_utils::Expiration;
2use dao_voting::{
3 status::Status,
4 threshold::{PercentageThreshold, Threshold},
5 voting::Votes,
6};
7
8pub(crate) fn v1_expiration_to_v2(v1: cw_utils_v1::Expiration) -> Expiration {
9 match v1 {
10 cw_utils_v1::Expiration::AtHeight(height) => Expiration::AtHeight(height),
11 cw_utils_v1::Expiration::AtTime(time) => Expiration::AtTime(time),
12 cw_utils_v1::Expiration::Never {} => Expiration::Never {},
13 }
14}
15
16pub(crate) fn v1_percentage_threshold_to_v2(
17 v1: voting_v1::PercentageThreshold,
18) -> PercentageThreshold {
19 match v1 {
20 voting_v1::PercentageThreshold::Majority {} => PercentageThreshold::Majority {},
21 voting_v1::PercentageThreshold::Percent(p) => PercentageThreshold::Percent(p),
22 }
23}
24
25pub(crate) fn v1_threshold_to_v2(v1: voting_v1::Threshold) -> Threshold {
26 match v1 {
27 voting_v1::Threshold::AbsolutePercentage { percentage } => Threshold::AbsolutePercentage {
28 percentage: v1_percentage_threshold_to_v2(percentage),
29 },
30 voting_v1::Threshold::ThresholdQuorum { threshold, quorum } => Threshold::ThresholdQuorum {
31 threshold: v1_percentage_threshold_to_v2(threshold),
32 quorum: v1_percentage_threshold_to_v2(quorum),
33 },
34 voting_v1::Threshold::AbsoluteCount { threshold } => Threshold::AbsoluteCount { threshold },
35 }
36}
37
38pub(crate) fn v1_status_to_v2(v1: voting_v1::Status) -> Status {
39 match v1 {
40 voting_v1::Status::Open => Status::Open,
41 voting_v1::Status::Rejected => Status::Rejected,
42 voting_v1::Status::Passed => Status::Passed,
43 voting_v1::Status::Executed => Status::Executed,
44 voting_v1::Status::Closed => Status::Closed,
45 }
46}
47
48pub(crate) fn v1_votes_to_v2(v1: voting_v1::Votes) -> Votes {
49 Votes {
50 yes: v1.yes,
51 no: v1.no,
52 abstain: v1.abstain,
53 }
54}