Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CW2: add a method to assert contract version #858

Merged
merged 3 commits into from
Mar 7, 2023

Conversation

larry0x
Copy link
Contributor

@larry0x larry0x commented Feb 8, 2023

Closes: #857

@CLAassistant
Copy link

CLAassistant commented Feb 8, 2023

CLA assistant check
All committers have signed the CLA.

@larry0x
Copy link
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
Collaborator

I like it. Thanks @larry0x!

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

packages/cw2/src/lib.rs Show resolved Hide resolved
@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