-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
164 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
use std::fmt; | ||
|
||
use cosmwasm_schema::cw_serde; | ||
use cosmwasm_std::{Addr, Uint128}; | ||
use cw_utils::Expiration; | ||
|
||
use crate::fees::FeeInformation; | ||
|
||
use super::state::{Competition, CompetitionStatus}; | ||
|
||
/// Used for migration | ||
#[cw_serde] | ||
pub enum CompetitionStatusV182 { | ||
Pending, | ||
Active, | ||
Inactive, | ||
Jailed, | ||
} | ||
|
||
impl fmt::Display for CompetitionStatusV182 { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
match self { | ||
CompetitionStatusV182::Pending => write!(f, "Pending"), | ||
CompetitionStatusV182::Jailed => write!(f, "Jailed"), | ||
CompetitionStatusV182::Active => write!(f, "Active"), | ||
CompetitionStatusV182::Inactive => write!(f, "Inactive"), | ||
} | ||
} | ||
} | ||
|
||
/// Used for migration | ||
#[cw_serde] | ||
pub struct CompetitionV182<CompetitionExt> { | ||
pub id: Uint128, | ||
pub category_id: Option<Uint128>, | ||
pub admin_dao: Addr, | ||
pub host: Addr, | ||
pub escrow: Option<Addr>, | ||
pub name: String, | ||
pub description: String, | ||
pub start_height: u64, | ||
pub expiration: Expiration, | ||
pub rulesets: Option<Vec<Uint128>>, | ||
pub status: CompetitionStatusV182, | ||
pub extension: CompetitionExt, | ||
pub fees: Option<Vec<FeeInformation<Addr>>>, | ||
pub banner: Option<String>, | ||
} | ||
|
||
impl<CompetitionExt: Clone> CompetitionV182<CompetitionExt> { | ||
pub fn into_competition(self, activation_height: u64) -> Competition<CompetitionExt> { | ||
Competition { | ||
id: self.id, | ||
category_id: self.category_id, | ||
admin_dao: self.admin_dao, | ||
host: self.host, | ||
escrow: self.escrow, | ||
name: self.name, | ||
description: self.description, | ||
start_height: self.start_height, | ||
expiration: self.expiration, | ||
rulesets: self.rulesets, | ||
status: match self.status { | ||
CompetitionStatusV182::Pending => CompetitionStatus::Pending, | ||
CompetitionStatusV182::Active => CompetitionStatus::Active { activation_height }, | ||
CompetitionStatusV182::Inactive => CompetitionStatus::Inactive, | ||
CompetitionStatusV182::Jailed => CompetitionStatus::Jailed { activation_height }, | ||
}, | ||
extension: self.extension, | ||
fees: self.fees, | ||
banner: self.banner, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod migrate; | ||
pub mod msg; | ||
pub mod state; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters