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

Add contract's ink! compatibility check #1334

Merged
merged 16 commits into from
Oct 4, 2023
Merged

Add contract's ink! compatibility check #1334

merged 16 commits into from
Oct 4, 2023

Conversation

smiasojed
Copy link
Collaborator

@smiasojed smiasojed commented Sep 17, 2023

Add warning message when using incompatible contract's ink! version

Closes #754

  • [n] y/n | Does it introduce breaking changes?
  • [n] y/n | Is it dependent on the specific version of ink or pallet-contracts?

Description

Checks the compatibility of the contract's ink version with the cargo-contract. If a version mismatch is detected, a warning message will be displayed:
warning: The cargo-contract is not compatible with the contract's ink! version. Please update the cargo-contract to version '1.5.0' or update the contract ink! to a version of '^4.0.0-alpha.3', '^4.0.0', '^5.0.0-alpha'

Checklist before requesting a review

  • My code follows the style guidelines of this project
  • I have added an entry to CHANGELOG.md
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been merged and published in downstream modules

/// binary.
pub fn check_contract_ink_compatibility(ink_version: &Version) -> Result<()> {
let ink_minimal_version =
Version::parse("4.0.0-alpha.1").expect("Parsing version failed");
Copy link
Collaborator Author

@smiasojed smiasojed Sep 18, 2023

Choose a reason for hiding this comment

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

here dependency is hardcoded,
optionally we could have compatibility.json file:

{
   "versions": [
        {
            "cargo-contract": ">=1.0.0,<2.0.0",
            "ink": ">=3.0.0,<4.0.0"
        },
        {
            "cargo-contract": ">=4.0.0",
            "ink": ">=4.0.0"
        }
    ]
}

and include it to code (include_str)

@smiasojed smiasojed changed the title Sm/ink deps Add contract's ink! compatibility check Sep 18, 2023
@smiasojed smiasojed marked this pull request as ready for review September 26, 2023 07:48
crates/metadata/src/compatibility.rs Outdated Show resolved Hide resolved
crates/metadata/src/compatibility.rs Outdated Show resolved Hide resolved
crates/metadata/src/compatibility.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@ascjones ascjones left a comment

Choose a reason for hiding this comment

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

Looks good, a few improvements can be made to the readability of the comparison logic 👇

crates/metadata/src/compatibility.rs Outdated Show resolved Hide resolved
crates/metadata/src/compatibility.rs Outdated Show resolved Hide resolved
crates/metadata/src/compatibility.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@ascjones ascjones left a comment

Choose a reason for hiding this comment

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

LGTM

@ascjones ascjones merged commit 09864b6 into master Oct 4, 2023
10 checks passed
@ascjones ascjones deleted the sm/ink-deps branch October 4, 2023 10:24
@smiasojed smiasojed mentioned this pull request Nov 30, 2023
@smiasojed smiasojed mentioned this pull request Mar 4, 2024
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.

Detect incompatible version of ink
2 participants