Skip to content

Commit

Permalink
fix(assembly): remove direct migration to vxASTRO (#114)
Browse files Browse the repository at this point in the history
* fix(assembly): remove direct migration to vxASTRO

* revert astroport-governance crate bump
  • Loading branch information
epanchee authored Oct 1, 2024
1 parent d79c58e commit d4483ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 44 deletions.
9 changes: 0 additions & 9 deletions Cargo.lock

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

43 changes: 8 additions & 35 deletions contracts/assembly/src/migration.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
#![cfg(not(tarpaulin_include))]

use cosmwasm_schema::cw_serde;
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{Addr, CosmosMsg, DepsMut, Env, Order, Response, StdResult, Uint128, Uint64};
use cosmwasm_std::{
Addr, CosmosMsg, DepsMut, Empty, Env, Order, Response, StdResult, Uint128, Uint64,
};
use cw2::{get_contract_version, set_contract_version};
use cw_storage_plus::Map;

use astroport_governance::assembly::{Config, Proposal, ProposalStatus};
use astroport_governance::voting_escrow;
use astroport_governance::assembly::{Proposal, ProposalStatus};

use crate::contract::{CONTRACT_NAME, CONTRACT_VERSION};
use crate::error::ContractError;
use crate::state::{CONFIG, PROPOSALS};

#[cw_serde]
pub struct MigrateMsg {
pub vxastro_contract: String,
}
use crate::state::PROPOSALS;

#[cw_serde]
pub struct OldProposal {
Expand All @@ -44,34 +38,13 @@ pub struct OldProposal {

const OLD_PROPOSALS: Map<u64, OldProposal> = Map::new("proposals");

#[cfg_attr(not(feature = "library"), entry_point)]
pub fn migrate(deps: DepsMut, _env: Env, msg: MigrateMsg) -> Result<Response, ContractError> {
#[cfg_attr(not(feature = "library"), cosmwasm_std::entry_point)]
pub fn migrate(deps: DepsMut, _env: Env, _msg: Empty) -> Result<Response, ContractError> {
let contract_version = get_contract_version(deps.storage)?;

match contract_version.contract.as_ref() {
CONTRACT_NAME => match contract_version.version.as_ref() {
"2.0.0" => {
// vxastro and emissions_controller are optional fields,
// thus old config can be deserialized to new config
let config = CONFIG.load(deps.storage)?;

let emissions_controller = deps
.querier
.query_wasm_smart::<voting_escrow::Config>(
&msg.vxastro_contract,
&voting_escrow::QueryMsg::Config {},
)?
.emissions_controller;

CONFIG.save(
deps.storage,
&Config {
vxastro_contract: Some(Addr::unchecked(msg.vxastro_contract)),
emissions_controller: Some(emissions_controller),
..config
},
)?;

"2.0.1" => {
let proposals = OLD_PROPOSALS
.range(deps.storage, None, None, Order::Ascending)
.collect::<StdResult<Vec<_>>>()?;
Expand Down

0 comments on commit d4483ef

Please sign in to comment.