Skip to content

Commit

Permalink
fix(assembly): replace ListChannels with Channel query (v1.2.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
epanchee authored Oct 20, 2023
1 parent 8573d73 commit 82543a9
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 227 deletions.
20 changes: 10 additions & 10 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 contracts/assembly/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "astro-assembly"
version = "1.3.0"
version = "1.3.1"
authors = ["Astroport"]
edition = "2021"

Expand Down
38 changes: 16 additions & 22 deletions contracts/assembly/src/contract.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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()))
}
Expand All @@ -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<Response, ContractError> {
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() {
"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 {}),
Expand Down
2 changes: 0 additions & 2 deletions contracts/assembly/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
191 changes: 0 additions & 191 deletions contracts/assembly/src/migration.rs

This file was deleted.

2 changes: 1 addition & 1 deletion packages/astroport-governance/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 82543a9

Please sign in to comment.