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

Migrate uses upgrades/v0_17 #132

Open
taitruong opened this issue Jul 18, 2023 · 1 comment
Open

Migrate uses upgrades/v0_17 #132

taitruong opened this issue Jul 18, 2023 · 1 comment

Comments

@taitruong
Copy link
Collaborator

current version is v0.18 but it still uses this:

.add_attribute("from_version", "0.16.0")
.add_attribute("to_version", "0.17.0")

...
    Ok(Response::new()
        .add_attribute("action", "migrate")
        .add_attribute("from_version", "0.16.0")
        .add_attribute("to_version", "0.17.0")
        .add_attribute("old_minter", minter)
        .add_attributes(ownership.into_attributes()))

So response attributes are not correct. There are const like EXPECTED_FROM_VERSION and CONTRACT_VERSION it could use for from_version and to_version

@taitruong
Copy link
Collaborator Author

This migration does affect not only v0.16 - but also older versions. Migration logic assumes current contract is version v0.16 (and lower):

let tract16 = v16::Cw721Contract::<T, C, E, Q>::default();
let minter = tract16.minter.load(deps.storage)?;
tract16.minter.remove(deps.storage);
// save new ownership info
let ownership = cw_ownable::initialize_owner(deps.storage, deps.api, Some(minter.as_str()))?;

Instead it may query for ownership and if it doesn't exist, it could do a migration, like this:

// cw721 v0.17 and higher holds ownership in the contract
let ownership: StdResult<Ownership<Addr>> = deps
    .querier
    .query_wasm_smart(sender, &cw721_base::msg::QueryMsg::Ownership::<Addr> {});
if ownership.is_err() {
    // cw721 v0.16 and lower holds minter
    let minter_response: cw721_base_016::msg::MinterResponse = deps
        .querier
        .query_wasm_smart(sender, &cw721_base_016::QueryMsg::Minter::<Empty> {})?;
    // migration logic here...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant