-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* properly set new contract version in v1.1 upgrade * validate keys * v1.2 migrate * put updates under feature flags * some styling and code quality improvements * bump version to 1.2.0 * move all dependencies to workspace * update workspace profile * do not use `k256` inside a contract * determine `expected_version` by flag * bump dependency versions * add migrate entry point for nft contract * remove features (unnecessary)
- Loading branch information
Showing
23 changed files
with
393 additions
and
201 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
members = ["contracts/*", "packages/*"] | ||
|
||
[workspace.package] | ||
version = "1.1.0" | ||
version = "1.2.0" | ||
authors = ["larry <[email protected]>"] | ||
edition = "2021" | ||
homepage = "https://badges.fun" | ||
|
@@ -11,34 +11,32 @@ license = "GPL-3.0-or-later" | |
keywords = ["nft", "cosmos", "cosmwasm", "stargaze"] | ||
|
||
[workspace.dependencies] | ||
cosmwasm-schema = "1.0" | ||
cosmwasm-std = "1.0" | ||
cw2 = "0.13" | ||
cw721 = "0.13" | ||
cw721-base = "0.13" | ||
cw-storage-plus = "0.13" | ||
cw-utils = "0.13" | ||
cosmwasm-schema = "1.1" | ||
cosmwasm-std = "1.1" | ||
cw2 = "0.16" | ||
cw721 = "0.16" | ||
cw721-base = "0.16" | ||
cw-item-set = { version = "0.7", default-features = false, features = ["iterator"] } | ||
cw-storage-plus = "1.0" | ||
# we can't use cw-utils v1.0 because sg1 still uses 0.16 | ||
cw-utils = "0.16" | ||
hex = "0.4" | ||
schemars = "0.8" | ||
serde = { version = "1.0", default-features = false } | ||
sg1 = "0.14" | ||
sg721 = "0.14" | ||
# Stargaze team forgot to upload sg721-base v0.14 to crates.io | ||
sg721-base = { git = "https://github.com/public-awesome/launchpad", rev = "4183957" } | ||
sg-metadata = "0.14" | ||
sg-std = "0.14" | ||
|
||
[profile.release.package.badge-hub] | ||
codegen-units = 1 | ||
incremental = false | ||
|
||
[profile.release.package.badge-nft] | ||
codegen-units = 1 | ||
incremental = false | ||
sg1 = "0.21" | ||
sg721 = "0.21" | ||
sg721-base = "0.21" | ||
sg-metadata = "0.21" | ||
sg-std = "0.21" | ||
sha2 = "0.10" | ||
thiserror = "1" | ||
|
||
[profile.release] | ||
rpath = false | ||
lto = true | ||
overflow-checks = true | ||
opt-level = 3 | ||
debug = false | ||
codegen-units = 1 | ||
debug = false | ||
debug-assertions = false | ||
incremental = false | ||
lto = true | ||
opt-level = 3 | ||
overflow-checks = true | ||
rpath = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod v1_1; | ||
pub mod v1_2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use cosmwasm_std::{DepsMut, StdResult, Storage}; | ||
use sg_std::Response; | ||
|
||
use badges::MintRule; | ||
|
||
use crate::{ | ||
contract::{CONTRACT_NAME, CONTRACT_VERSION}, | ||
state::BADGES, | ||
}; | ||
|
||
const NEW_BADGE_17_KEY: &str = "036986114808be5b9f9009754014bdf5ae210cc17c93f4e1d010164be74b8653f4"; | ||
|
||
pub fn migrate(deps: DepsMut) -> StdResult<Response> { | ||
// correct the claim key of badge 17 | ||
update_badge_17_key(deps.storage)?; | ||
|
||
// set the contract version to v1.2.0 | ||
cw2::set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; | ||
|
||
Ok(Response::new() | ||
.add_attribute("action", "badges/hub/migrate") | ||
.add_attribute("from_version", "1.1.0") | ||
.add_attribute("to_version", "1.2.0")) | ||
} | ||
|
||
fn update_badge_17_key(store: &mut dyn Storage) -> StdResult<()> { | ||
BADGES.update(store, 17, |opt| -> StdResult<_> { | ||
let mut badge = opt.unwrap(); | ||
badge.rule = MintRule::ByKey(NEW_BADGE_17_KEY.into()); | ||
Ok(badge) | ||
})?; | ||
Ok(()) | ||
} |
Oops, something went wrong.