Skip to content

Commit

Permalink
Add migration for incentive state
Browse files Browse the repository at this point in the history
  • Loading branch information
mappum committed Jul 31, 2023
1 parent e6cd541 commit c03b405
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/incentives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::{
app::Nom,
error::{Error, Result},
};
use orga::migrate::MigrateFrom;
use orga::{
coins::{Address, Amount, Coin, Take},
collections::{ChildMut, Map},
Expand All @@ -17,11 +18,27 @@ pub struct Incentives {
accounts: Map<Address, Account>,
}

#[orga]
#[orga(version = 1)]
pub struct Account {
#[orga(version(V0))]
testnet_participation: Coin<Nom>,

#[orga(version(V1))]
testnet_participation: Part,
}

impl MigrateFrom<AccountV0> for AccountV1 {
fn migrate_from(old: AccountV0) -> orga::Result<Self> {
Ok(AccountV1 {
testnet_participation: Part {
locked: 0,
claimable: old.testnet_participation.amount.into(),
claimed: 0,
},
})
}
}

#[orga]
impl Incentives {
pub fn from_csv(data: &[u8], mut funds: Coin<Nom>) -> Result<Self> {
Expand Down

0 comments on commit c03b405

Please sign in to comment.