diff --git a/Cargo.lock b/Cargo.lock index b4005bad..59143ccf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -21,11 +21,11 @@ checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" [[package]] name = "astro-assembly" -version = "1.3.0" +version = "1.3.1" dependencies = [ "anyhow", "astroport", - "astroport-governance 1.2.0", + "astroport-governance 1.2.1", "astroport-staking", "astroport-token", "astroport-xastro-token", @@ -60,7 +60,7 @@ dependencies = [ name = "astroport-escrow-fee-distributor" version = "1.0.1" dependencies = [ - "astroport-governance 1.2.0", + "astroport-governance 1.2.1", "astroport-tests", "astroport-token", "cosmwasm-schema", @@ -107,6 +107,7 @@ dependencies = [ [[package]] name = "astroport-governance" version = "1.2.0" +source = "git+https://github.com/astroport-fi/astroport-governance.git?branch=feat/fix_deps#4ab8725173a4476d0a819c9b54ddadd21e024476" dependencies = [ "astroport", "cosmwasm-schema", @@ -118,7 +119,7 @@ dependencies = [ [[package]] name = "astroport-governance" version = "1.2.0" -source = "git+https://github.com/astroport-fi/astroport-governance.git?branch=feat/fix_deps#4ab8725173a4476d0a819c9b54ddadd21e024476" +source = "git+https://github.com/astroport-fi/astroport-governance.git?branch=release#a707945bd5c271c6a4dfc2a21a563e902376ce83" dependencies = [ "astroport", "cosmwasm-schema", @@ -129,8 +130,7 @@ dependencies = [ [[package]] name = "astroport-governance" -version = "1.2.0" -source = "git+https://github.com/astroport-fi/astroport-governance.git?branch=release#a707945bd5c271c6a4dfc2a21a563e902376ce83" +version = "1.2.1" dependencies = [ "astroport", "cosmwasm-schema", @@ -179,7 +179,7 @@ dependencies = [ "astroport-escrow-fee-distributor", "astroport-factory", "astroport-generator", - "astroport-governance 1.2.0", + "astroport-governance 1.2.1", "astroport-pair", "astroport-staking", "astroport-token", @@ -303,7 +303,7 @@ name = "builder-unlock" version = "1.2.2" dependencies = [ "astroport", - "astroport-governance 1.2.0", + "astroport-governance 1.2.1", "astroport-token", "cosmwasm-schema", "cosmwasm-std", @@ -726,7 +726,7 @@ dependencies = [ "anyhow", "astroport-factory", "astroport-generator", - "astroport-governance 1.2.0", + "astroport-governance 1.2.1", "astroport-pair", "astroport-staking", "astroport-tests", @@ -1353,7 +1353,7 @@ version = "1.2.0" dependencies = [ "anyhow", "astroport-escrow-fee-distributor", - "astroport-governance 1.2.0", + "astroport-governance 1.2.1", "astroport-staking", "astroport-token", "cosmwasm-schema", diff --git a/contracts/assembly/Cargo.toml b/contracts/assembly/Cargo.toml index c13dd802..00acd796 100644 --- a/contracts/assembly/Cargo.toml +++ b/contracts/assembly/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "astro-assembly" -version = "1.3.0" +version = "1.3.1" authors = ["Astroport"] edition = "2021" diff --git a/contracts/assembly/src/contract.rs b/contracts/assembly/src/contract.rs index 4a4e8190..9587f58d 100644 --- a/contracts/assembly/src/contract.rs +++ b/contracts/assembly/src/contract.rs @@ -1,29 +1,26 @@ +use std::str::FromStr; + +use astroport::xastro_token::QueryMsg as XAstroTokenQueryMsg; use cosmwasm_std::{ - attr, entry_point, from_binary, to_binary, wasm_execute, Addr, Binary, CosmosMsg, Decimal, - Deps, DepsMut, Env, IbcQuery, ListChannelsResponse, MessageInfo, Order, QuerierWrapper, - QueryRequest, Response, StdResult, Uint128, Uint64, WasmMsg, + attr, entry_point, from_binary, to_binary, wasm_execute, Addr, Binary, ChannelResponse, + CosmosMsg, Decimal, Deps, DepsMut, Empty, Env, IbcQuery, MessageInfo, Order, QuerierWrapper, + Response, StdResult, Uint128, Uint64, WasmMsg, }; use cw2::{get_contract_version, set_contract_version}; use cw20::{BalanceResponse, Cw20ExecuteMsg, Cw20ReceiveMsg}; use cw_storage_plus::Bound; -use std::str::FromStr; use astroport_governance::assembly::{ helpers::validate_links, Config, Cw20HookMsg, ExecuteMsg, InstantiateMsg, Proposal, ProposalListResponse, ProposalStatus, ProposalVoteOption, ProposalVotesResponse, QueryMsg, UpdateConfig, }; - -use astroport::xastro_token::QueryMsg as XAstroTokenQueryMsg; use astroport_governance::builder_unlock::msg::{ AllocationResponse, QueryMsg as BuilderUnlockQueryMsg, StateResponse, }; use astroport_governance::voting_escrow::{QueryMsg as VotingEscrowQueryMsg, VotingPowerResponse}; use crate::error::ContractError; -use crate::migration::{ - migrate_config, migrate_proposals_from_v110, migrate_proposals_from_v121, MigrateMsg, -}; use crate::state::{CONFIG, PROPOSALS, PROPOSAL_COUNT}; // Contract name and version used for migration. @@ -918,11 +915,14 @@ pub fn check_controller_supports_channel( given_channel: &String, ) -> Result<(), ContractError> { let port_id = Some(format!("wasm.{ibc_controller}")); - let ListChannelsResponse { channels } = - querier.query(&QueryRequest::Ibc(IbcQuery::ListChannels { port_id }))?; - channels - .iter() - .find(|channel| &channel.endpoint.channel_id == given_channel) + let ChannelResponse { channel } = querier.query( + &IbcQuery::Channel { + channel_id: given_channel.to_string(), + port_id, + } + .into(), + )?; + channel .map(|_| ()) .ok_or_else(|| ContractError::InvalidChannel(given_channel.to_string())) } @@ -936,18 +936,12 @@ pub fn check_controller_supports_channel( /// /// * **msg** is an object of type [`MigrateMsg`]. #[cfg_attr(not(feature = "library"), entry_point)] -pub fn migrate(mut deps: DepsMut, _env: Env, msg: MigrateMsg) -> Result { +pub fn migrate(deps: DepsMut, _env: Env, _msg: Empty) -> Result { let contract_version = get_contract_version(deps.storage)?; match contract_version.contract.as_ref() { "astro-assembly" => match contract_version.version.as_ref() { - "1.1.0" => { - migrate_config(&mut deps, &msg)?; - migrate_proposals_from_v110(deps.storage)?; - } - "1.2.1" => { - migrate_proposals_from_v121(deps.storage)?; - } + "1.3.0" => {} _ => return Err(ContractError::MigrationError {}), }, _ => return Err(ContractError::MigrationError {}), diff --git a/contracts/assembly/src/lib.rs b/contracts/assembly/src/lib.rs index fe535ffc..bf63aa64 100644 --- a/contracts/assembly/src/lib.rs +++ b/contracts/assembly/src/lib.rs @@ -2,8 +2,6 @@ pub mod contract; pub mod error; pub mod state; -mod migration; - // During development this import could be replaced with another astroport version. // However, in production, the astroport version should be the same for all contracts. pub use astroport_governance::astroport; diff --git a/contracts/assembly/src/migration.rs b/contracts/assembly/src/migration.rs deleted file mode 100644 index adcdf006..00000000 --- a/contracts/assembly/src/migration.rs +++ /dev/null @@ -1,191 +0,0 @@ -use cosmwasm_schema::cw_serde; -use cosmwasm_std::{Addr, CosmosMsg, Decimal, DepsMut, StdResult, Storage, Uint128, Uint64}; -use cw_storage_plus::{Item, Map}; - -use astroport_governance::assembly::{Config, Proposal, ProposalStatus}; - -use crate::state::{CONFIG, PROPOSALS}; - -use cosmwasm_schema::schemars; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; - -/// This structure describes a migration message. -#[cw_serde] -pub struct MigrateMsg { - ibc_controller: Option, -} - -pub fn migrate_config(deps: &mut DepsMut, msg: &MigrateMsg) -> StdResult<()> { - #[cw_serde] - struct ConfigV110 { - pub xastro_token_addr: Addr, - pub vxastro_token_addr: Option, - pub builder_unlock_addr: Addr, - pub proposal_voting_period: u64, - pub proposal_effective_delay: u64, - pub proposal_expiration_period: u64, - pub proposal_required_deposit: Uint128, - pub proposal_required_quorum: Decimal, - pub proposal_required_threshold: Decimal, - pub whitelisted_links: Vec, - } - - let config: ConfigV110 = Item::new("config").load(deps.storage)?; - let mut config = Config { - builder_unlock_addr: config.builder_unlock_addr, - ibc_controller: None, - proposal_effective_delay: config.proposal_effective_delay, - proposal_expiration_period: config.proposal_expiration_period, - proposal_required_deposit: config.proposal_required_deposit, - proposal_required_quorum: config.proposal_required_quorum, - proposal_required_threshold: config.proposal_required_threshold, - proposal_voting_period: config.proposal_voting_period, - vxastro_token_addr: config.vxastro_token_addr, - whitelisted_links: config.whitelisted_links, - xastro_token_addr: config.xastro_token_addr, - }; - - if let Some(ref ibc_controller) = msg.ibc_controller { - config.ibc_controller = Some(deps.api.addr_validate(ibc_controller)?); - } - - CONFIG.save(deps.storage, &config)?; - - Ok(()) -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] -enum ProposalStatus110 { - Active, - Executed, - Expired, - Passed, - Rejected, -} - -/// This structure describes an old proposal message. -#[cw_serde] -pub struct OldProposalMessage { - /// Order of execution of the message - pub order: Uint64, - /// Execution message - pub msg: CosmosMsg, -} - -#[cw_serde] -struct ProposalV110 { - pub proposal_id: Uint64, - pub submitter: Addr, - pub status: ProposalStatus110, - pub for_power: Uint128, - pub against_power: Uint128, - pub for_voters: Vec, - pub against_voters: Vec, - pub start_block: u64, - pub start_time: u64, - pub end_block: u64, - pub title: String, - pub description: String, - pub link: Option, - pub messages: Option>, - pub deposit_amount: Uint128, -} - -const PROPOSALS_V110: Map = Map::new("proposals"); - -pub fn migrate_proposals_from_v110(storage: &mut dyn Storage) -> StdResult<()> { - let proposals = PROPOSALS_V110 - .range(storage, None, None, cosmwasm_std::Order::Ascending {}) - .collect::>>()?; - - for (key, proposal) in proposals { - PROPOSALS.save( - storage, - key, - &Proposal { - proposal_id: proposal.proposal_id, - submitter: proposal.submitter, - status: match proposal.status { - ProposalStatus110::Active => ProposalStatus::Active, - ProposalStatus110::Executed => ProposalStatus::Executed, - ProposalStatus110::Expired => ProposalStatus::Expired, - ProposalStatus110::Passed => ProposalStatus::Passed, - ProposalStatus110::Rejected => ProposalStatus::Rejected, - }, - for_power: proposal.for_power, - against_power: proposal.against_power, - for_voters: proposal.for_voters, - against_voters: proposal.against_voters, - start_block: proposal.start_block, - start_time: proposal.start_time, - end_block: proposal.end_block, - title: proposal.title, - description: proposal.description, - link: proposal.link, - messages: proposal - .messages - .map(|v| v.into_iter().map(|m| m.msg).collect()), - deposit_amount: proposal.deposit_amount, - ibc_channel: None, - }, - )?; - } - Ok(()) -} - -#[cw_serde] -pub struct ProposalV121 { - pub proposal_id: Uint64, - pub submitter: Addr, - pub status: ProposalStatus, - pub for_power: Uint128, - pub against_power: Uint128, - pub for_voters: Vec, - pub against_voters: Vec, - pub start_block: u64, - pub start_time: u64, - pub end_block: u64, - pub title: String, - pub description: String, - pub link: Option, - pub messages: Option>, - pub deposit_amount: Uint128, - pub ibc_channel: Option, -} - -const PROPOSALS_V121: Map = Map::new("proposals"); - -pub fn migrate_proposals_from_v121(storage: &mut dyn Storage) -> StdResult<()> { - let proposals = PROPOSALS_V121 - .range(storage, None, None, cosmwasm_std::Order::Ascending {}) - .collect::>>()?; - - for (key, proposal) in proposals { - PROPOSALS.save( - storage, - key, - &Proposal { - proposal_id: proposal.proposal_id, - submitter: proposal.submitter, - status: proposal.status, - for_power: proposal.for_power, - against_power: proposal.against_power, - for_voters: proposal.for_voters, - against_voters: proposal.against_voters, - start_block: proposal.start_block, - start_time: proposal.start_time, - end_block: proposal.end_block, - title: proposal.title, - description: proposal.description, - link: proposal.link, - messages: proposal - .messages - .map(|v| v.into_iter().map(|m| m.msg).collect()), - deposit_amount: proposal.deposit_amount, - ibc_channel: proposal.ibc_channel, - }, - )?; - } - Ok(()) -} diff --git a/packages/astroport-governance/Cargo.toml b/packages/astroport-governance/Cargo.toml index af3b4268..5ade1429 100644 --- a/packages/astroport-governance/Cargo.toml +++ b/packages/astroport-governance/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "astroport-governance" -version = "1.2.0" +version = "1.2.1" authors = ["Astroport"] edition = "2021" repository = "https://github.com/astroport-fi/astroport-governance"