Open ma96o opened 2 years ago
ちなみに,SPDX license identifiersは SPDX を利用してコードのライセンスを明示するもの. そして SPDX とは,Linux Foundation のプロジェクトで、「ソフトウェアのライセンスやコンポーネント,コピーライト,セキュリティーリファレンスといった情報を記述する標準形式」を定めようとするもの. 具体的には,ソフトウェアのパッケージに含まれるデータをやり取りする際の標準的なフォーマットを提供している. HPは https://spdx.dev/ ライセンスリストはSPDX License Listで見ることができる.
Visual Studio Code で開発を行うと,バックグラウンド分析により警告を表示してくれる. 大体は気になりつつも,その場しのぎで対応してしまっているので,今日は Solidity 開発において初歩的な内容について,いくつか事例を挙げ対応策をまとめた.
1.
SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
現象
原因
SPDX license identifiers を指定していないから Solidity はv0.6.8からSPDX license identifiersを取り入れた
解決策
SPDX license identifiersを明示する(↓は [UNLICENSED] の場合)
2.
Source file requires different compiler version (current compiler is 0.8.13+commit.abaa5c0e.Emscripten.clang) - note that nightly builds are considered to be strictly less than the released version
現象
原因
Visual Studio Code の workspace compiler のバージョンが,指定したものよりも低いから
解決策
workspace compiler をコードで指定したものに揃える
ref. How to Change the Solidity Compiler in VS Code - Dapp Dev Tips - Medium
3.
Source "XXX.sol" not found: File import callback not supported
現象
原因
node_modules/
配下のライブラリを呼んでいないため解決策
デフォルトのパッケージパスに
node_modules/
を指定settings.json
に↓の記述を追加ref. https://ethereum.stackexchange.com/a/111572