🥂

Ink! 3.0.0-rc9 で今までの ink! プロジェクトのビルドが通らなくなったら

2022/02/28に公開

ある日 おもむろに ink! プロジェクトをビルドすると、
以下のビルドエラーが発生した。

$ cargo +nightly contract build
error: There are multiple `parity-scale-codec` packages in your project, and the specification `parity-scale-codec` is ambiguous.
Please re-run this command with `-p <spec>` where `<spec>` is one of the following:
  parity-scale-codec:2.3.1
  parity-scale-codec:3.0.0
ERROR: Mismatching versions of `parity-scale-codec` were found!
Please ensure that your contract and your ink! dependencies use a compatible version of this package.

parity-scale-codec がなんかおかしい、と。

何も考えずに、ink! 3.0.0-rc9 のリリース通知を見てみる。

https://github.com/paritytech/ink/blob/v3.0.0-rc9/RELEASES.md

please-upgrade-scale-info-and-parity-scale-codec-in-your-contracts-dependencies

とのことなので、 cargo.toml の当該箇所を書き換える。

・・省略・・
- scale = { package = "parity-scale-codec", version = "2.1", default-features = false, features = ["derive"] }
- scale-info = { version = "1.0.0", default-features = false, features = ["derive"], optional = true }
+ scale-info = { version = "2", default-features = false, features = ["derive"], optional = true }
+ scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive", "full"] }

・・省略・・

祈りながらビルドしてみる。

$ cargo +nightly contract build
・・省略・・
   Compiling test v0.1.0 (/tmp/cargo-contract_rF3NK4)
   Compiling metadata-gen v0.1.0 (/tmp/cargo-contract_rF3NK4/.ink/metadata_gen)
    Finished release [optimized] target(s) in 17.83s

ktkr!!!!!!!!!!!

Discussion