Useful feature for migration support.
Pretty much every contract uses cw2 to store the version as defined by cargo:
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");
This is a string however, and not the easiest to use in migrate. to say, "allow migration where version.major == 0 && [8..-=10].contains(version.minor)".
As a first step, is a utility to parse a valid semver string into:
pub Semver struct {
pub major: u32;
pub minor: u32;
pub patch: u32;
// if you think this needs even more structure here, feel free to add
pub tag: Option<String>;
}
Also please add some basic constructors and implement Ord, so we can do something like:
if version < Semver::new(0, 8, 0) {
return Err("too low");
} else if version >= Semver::new(0, 10, 1) {
return Err("too high");
} else {
// do migration
}
The types above are meant to give inspiration and you can change them if you have a better idea that fulfills the same purpose.
Useful feature for migration support.
Pretty much every contract uses cw2 to store the version as defined by cargo:
const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");This is a string however, and not the easiest to use in migrate. to say, "allow migration where
version.major == 0 && [8..-=10].contains(version.minor)".As a first step, is a utility to parse a valid semver string into:
Also please add some basic constructors and implement Ord, so we can do something like:
The types above are meant to give inspiration and you can change them if you have a better idea that fulfills the same purpose.