You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A major use case of cw2 is when migrating a contract, check the stored version info to make sure we're not migrating a wrong contract, or migrating from a wrong version. Therefore, it makes sense to add a VersionError type which is to be emitted if this check fails:
#[derive(thiserror::Error,Debug)]enumVersionError{#[error("contract version info not found")]NotFound,#[error("wrong contract: expecting `{expected}`, found `{found}`")]WrongContract{expected:String,found:String,},#[error("wrong contract version: expecting `{expected}`, found `{found}`")]WrongVersion{expected:String,found:String,},}
// run this as part of the migration processfnassert_version(storage:&dynStorage,expected_contract:&str,expected_version:&str,) -> Result<(),VersionError>{letSome(ContractVersion{ contract, version }) = CONTRACT.may_load(storage)? else{
return Err(VersionError::NotFound);};if contract != expected_contract {returnErr(VersionError::WrongContract{expected: expected_contract.into(),found: contract,});}if version != expected_version {returnErr(VersionError::WrongVersion{expected: expected_version.into(),found: version,});}Ok(())}
The text was updated successfully, but these errors were encountered:
A major use case of cw2 is when migrating a contract, check the stored version info to make sure we're not migrating a wrong contract, or migrating from a wrong version. Therefore, it makes sense to add a
VersionError
type which is to be emitted if this check fails:The text was updated successfully, but these errors were encountered: