Errors when using "cargo-contract" v 5.0.3.
I was doing this ink! example . When I did "cargo contract build" , I would always get this error:
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.
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!.
@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 (https://github.com/use-ink/cargo-contract/pull/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.
@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.
@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.
@davidsemakula adding #[allow(clippy::cast_possible_truncation)] fixes the problem, thank you!
Closing as root cause was solved upstream in parity-scale-code, see links below for details
- https://github.com/paritytech/parity-scale-codec/issues/713
- https://github.com/paritytech/parity-scale-codec/pull/715