Remove migration code (#1027)

This commit is contained in:
Bogdan-Ștefan Neacşu
2022-01-13 12:59:56 +02:00
committed by GitHub
parent 3924c53d09
commit bc5e19514e
+1 -55
View File
@@ -291,61 +291,7 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> Result<QueryResponse, Cont
Ok(query_res?)
}
#[entry_point]
pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result<Response, ContractError> {
#[derive(serde::Serialize, serde::Deserialize, Clone)]
pub struct StoredMixnodeBondOld {
pub pledge_amount: mixnet_contract_common::Coin,
pub owner: Addr,
pub layer: mixnet_contract_common::Layer,
pub block_height: u64,
pub mix_node: mixnet_contract_common::MixNode,
pub profit_margin_percent: Option<u8>,
pub proxy: Option<Addr>,
}
pub struct MixnodeBondIndexOld<'a> {
pub owner: cw_storage_plus::UniqueIndex<'a, Addr, StoredMixnodeBondOld>,
}
impl<'a> cw_storage_plus::IndexList<StoredMixnodeBondOld> for MixnodeBondIndexOld<'a> {
fn get_indexes(
&'_ self,
) -> Box<dyn Iterator<Item = &'_ dyn cw_storage_plus::Index<StoredMixnodeBondOld>> + '_>
{
let v: Vec<&dyn cw_storage_plus::Index<StoredMixnodeBondOld>> = vec![&self.owner];
Box::new(v.into_iter())
}
}
pub(crate) fn mixnodes_old<'a>() -> cw_storage_plus::IndexedMap<
'a,
mixnet_contract_common::IdentityKeyRef<'a>,
StoredMixnodeBondOld,
MixnodeBondIndexOld<'a>,
> {
let indexes = MixnodeBondIndexOld {
owner: cw_storage_plus::UniqueIndex::new(|d| d.owner.clone(), "mno"),
};
cw_storage_plus::IndexedMap::new("mno", indexes)
}
let stored_mixnode_bonds: Vec<_> = mixnodes_old()
.range(deps.storage, None, None, cosmwasm_std::Order::Ascending)
.flatten()
.map(|record| crate::mixnodes::storage::StoredMixnodeBond {
pledge_amount: record.1.pledge_amount,
owner: record.1.owner,
layer: record.1.layer,
block_height: record.1.block_height,
mix_node: record.1.mix_node,
proxy: record.1.proxy,
})
.collect();
for stored_mixnode_bond in stored_mixnode_bonds {
crate::mixnodes::storage::mixnodes().save(
deps.storage,
stored_mixnode_bond.identity(),
&stored_mixnode_bond,
)?;
}
pub fn migrate(_deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result<Response, ContractError> {
Ok(Default::default())
}