Skip to content

Commit

Permalink
extend the minting deadline for badge 3
Browse files Browse the repository at this point in the history
  • Loading branch information
larry0x committed Oct 19, 2022
1 parent 90ff373 commit e4a8e6a
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions contracts/hub/src/upgrades/v1_1.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
use cosmwasm_std::{Decimal, DepsMut, StdResult};
use cosmwasm_std::{Decimal, DepsMut, StdResult, Storage};
use cw_storage_plus::Item;
use sg_std::Response;

use badges::FeeRate;

use crate::state::FEE_RATE;
use crate::state::{BADGES, FEE_RATE};

const LEGACY_FEE_PER_BYTE: Item<Decimal> = Item::new("fee_per_byte");

/// Date and time (GMT): Wednesday, November 30, 2022 11:59:59 PM
const NEW_BADGE_3_EXPIRY: u64 = 1669852799;

pub fn migrate(deps: DepsMut, fee_rate: FeeRate) -> StdResult<Response> {
update_fee_rate(deps, &fee_rate)?;
// set separate fee rates for metadata and keys
update_fee_rate(deps.storage, &fee_rate)?;

// extend the minting deadline for badge 3
update_badge_3_expiry(deps.storage)?;

Ok(Response::new()
.add_attribute("action", "badges/hub/migrate")
Expand All @@ -19,7 +26,20 @@ pub fn migrate(deps: DepsMut, fee_rate: FeeRate) -> StdResult<Response> {
.add_attribute("key_fee_rate", fee_rate.key.to_string()))
}

fn update_fee_rate(deps: DepsMut, fee_rate: &FeeRate) -> StdResult<()> {
LEGACY_FEE_PER_BYTE.remove(deps.storage);
FEE_RATE.save(deps.storage, fee_rate)
fn update_fee_rate(store: &mut dyn Storage, fee_rate: &FeeRate) -> StdResult<()> {
LEGACY_FEE_PER_BYTE.remove(store);
FEE_RATE.save(store, fee_rate)
}

fn update_badge_3_expiry(store: &mut dyn Storage) -> StdResult<()> {
BADGES.update(
store,
3,
|opt| {
let mut badge = opt.unwrap();
badge.expiry = Some(NEW_BADGE_3_EXPIRY);
Ok(badge)
},
)
.map(|_| ())
}

0 comments on commit e4a8e6a

Please sign in to comment.