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

Errors when using "cargo-contract" v 5.0.3. #73

Open
CasiniNift opened this issue Feb 25, 2025 · 5 comments
Open

Errors when using "cargo-contract" v 5.0.3. #73

CasiniNift opened this issue Feb 25, 2025 · 5 comments

Comments

@CasiniNift
Copy link

I was doing this ink! example . When I did "cargo contract build" , I would always get this error:
Image

If I use cargo contract v 4.1.1, I don't get any issues.

I think there are several ink! examples in the repo that do not work if you use v5 for cargo contracts.

@realtakahashi
Copy link

I got same errors.
But this project is compiled by using cargo-contract "4.1.1".
So I think this project might not be compatible with latest version of ink!.

Image Image

@davidsemakula
Copy link

@CasiniNift @realtakahashi Thanks for reporting.

This is likely caused by "unsafe" usize to u8 conversions originating from code generated by the derived implementations of the SCALE Encode and Decode traits.

cargo-contract v5.0.3 (https://github.com/use-ink/cargo-contract/releases/tag/v5.0.3) introduced these checks against such "unsafe" conversions.

You can read more about it in this PR (use-ink/cargo-contract#1895).

For now, if this is blocking you, you can use cargo-contract v5.0.2, as we figure out the best way to handle this case.

@CasiniNift
Copy link
Author

CasiniNift commented Feb 25, 2025

@davidsemakula thank you for the clarification. I have the same error when I use v5.0.2. I am using the same code in the example.

@davidsemakula
Copy link

davidsemakula commented Feb 25, 2025

@CasiniNift be sure to run cargo clean before running cargo contract build after installing v5.0.2

If that sill fails for some reason, you can try adding #[allow(clippy::cast_possible_truncation)] just above this line. That should disable the check for the offending Enum in this example.

@CasiniNift
Copy link
Author

@davidsemakula adding #[allow(clippy::cast_possible_truncation)] fixes the problem, thank you!

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

No branches or pull requests

3 participants