Skip to content

CW2: add a method to assert contract version#858

Merged
ueco-jb merged 3 commits intoCosmWasm:mainfrom
mars-protocol:cw2-new-error
Mar 7, 2023
Merged

CW2: add a method to assert contract version#858
ueco-jb merged 3 commits intoCosmWasm:mainfrom
mars-protocol:cw2-new-error

Conversation

@larry0x
Copy link
Copy Markdown
Contributor

@larry0x larry0x commented Feb 8, 2023

Closes: #857

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Feb 8, 2023

CLA assistant check
All committers have signed the CLA.

@larry0x
Copy link
Copy Markdown
Contributor Author

larry0x commented Feb 8, 2023

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
Copy link
Copy Markdown

I like it. Thanks @larry0x!

Copy link
Copy Markdown
Contributor

@ueco-jb ueco-jb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Thank you, a very nice addon

@ueco-jb ueco-jb merged commit 9c1daf7 into CosmWasm:main Mar 7, 2023
@apollo-sturdy apollo-sturdy mentioned this pull request Jun 6, 2023
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

Successfully merging this pull request may close these issues.

CW2: add a cw2::VersionError error type

4 participants