Skip to content

Commit

Permalink
fix storage versions (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
GadAlmighty authored Jul 4, 2023
1 parent b5c131a commit 10b4517
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 13 deletions.
55 changes: 55 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["packages/*", "contracts/dca", "contracts/exchanges/fin"]
members = ["packages/*", "contracts/dca", "contracts/exchanges/*"]

[profile.release]
opt-level = 3
Expand Down
2 changes: 1 addition & 1 deletion contracts/dca/src/state/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::types::config::Config;
use cosmwasm_std::{StdResult, Storage};
use cw_storage_plus::Item;

const CONFIG: Item<Config> = Item::new("config_v9");
const CONFIG: Item<Config> = Item::new("config_v31");

pub fn get_config(store: &dyn Storage) -> StdResult<Config> {
CONFIG.load(store)
Expand Down
6 changes: 3 additions & 3 deletions contracts/dca/src/state/disburse_escrow_tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ fn disburse_escrow_task_store<'a>(
let indexes = DisburseEscrowTaskIndexes {
due_date: MultiIndex::new(
|_, (due_date, _)| *due_date,
"disburse_escrow_task_v8",
"disburse_escrow_task_v8__due_date",
"disburse_escrow_task_v20",
"disburse_escrow_task_v20__due_date",
),
};
IndexedMap::new("disburse_escrow_task_v8", indexes)
IndexedMap::new("disburse_escrow_task_v20", indexes)
}

pub fn save_disburse_escrow_task(
Expand Down
11 changes: 3 additions & 8 deletions contracts/dca/src/state/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::types::event::{Event, EventBuilder};
use cosmwasm_std::{from_binary, to_binary, Binary, StdResult, Storage};
use cw_storage_plus::{Index, IndexList, IndexedMap, Item, UniqueIndex};

const EVENT_COUNTER: Item<u64> = Item::new("event_counter_v26");
const EVENT_COUNTER: Item<u64> = Item::new("event_counter_v20");

pub struct EventIndexes<'a> {
pub resource_id: UniqueIndex<'a, (u128, u64), Binary, u64>,
Expand All @@ -24,10 +24,10 @@ pub fn event_store<'a>() -> IndexedMap<'a, u64, Binary, EventIndexes<'a>> {
.map(|event: Event| (event.resource_id.into(), event.id))
.expect("deserialised event")
},
"serialised_events_v26__resource_id",
"serialised_events_v20__resource_id",
),
};
IndexedMap::new("serialised_events_v26", indexes)
IndexedMap::new("serialised_events_v20", indexes)
}

pub fn create_event(store: &mut dyn Storage, event_builder: EventBuilder) -> StdResult<u64> {
Expand All @@ -46,8 +46,3 @@ pub fn create_events(store: &mut dyn Storage, event_builders: Vec<EventBuilder>)
}
Ok(())
}

pub fn clear_events(store: &mut dyn Storage) {
event_store().clear(store);
EVENT_COUNTER.remove(store)
}

0 comments on commit 10b4517

Please sign in to comment.