CosmWasm / cw-plus

Production Quality contracts under open source licenses
Apache License 2.0
505 stars 352 forks source link

CW2: add a method to assert contract version #858

Closed larry0x closed 1 year ago

larry0x commented 1 year ago

Closes: #857

CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.

larry0x commented 1 year ago

I'd really like to use the let-else syntax, which imo is much nicer:

- let ContractVersion { contract, version } = match CONTRACT.may_load(storage)? {
-     Some(contract) => contract,
-     None => return Err(VersionError::NotFound),
- };
+ let Some(ContractVersion { contract, version }) = CONTRACT.may_load(storage)? else {
+     return Err(VersionError::NotFound);
+ };

Unfortunately it's only available after Rust 1.65, while CI is still on older versions.

JakeHartnell commented 1 year ago

I like it. Thanks @larry0x!