Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(assembly): remove direct migration to vxASTRO #114

Merged
merged 3 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading