ink icon indicating copy to clipboard operation
ink copied to clipboard

Automatically implement SpreadAllocate for ink! storage struct if all fields implement SpreadAllocate

Open Robbepop opened this issue 4 years ago • 3 comments

Currently the ink! codegen does not implement SpreadAllocate for the #[ink(storage)] struct.

This leads to us having to implement it manually in the adjusted ERC-20 example contract here: https://github.com/paritytech/ink/pull/979

Since ink! codegen already by default produces implementations for SpreadLayout for the #[ink(storage)] struct it would be natural to produce a SpreadAllocate implementation as well. The only downside is that while we enforce that all fields of the #[ink(storage)] struct implement SpreadLayout we cannot enforce the same for SpreadAllocate since that is more strict and not always needed for every ink! smart contract. Therefore we need to only implement SpreadAllocate automatically if all fields of the #[ink(storage)] struct implement it.

This issue requires adjustments in the ink_lang_codegen module.

Robbepop avatar Oct 30 '21 07:10 Robbepop

Close by #995.

HCastano avatar Nov 24 '21 17:11 HCastano

Close by #995.

Nope! This has not yet been implemented becaues rustc lacks the features to do so.

Robbepop avatar Nov 24 '21 18:11 Robbepop

The description of #995 should be updated to reflect that then

HCastano avatar Nov 25 '21 12:11 HCastano

Closing, as we removed anything SpreadLayout for ink! 4.0.

cmichi avatar Feb 17 '23 18:02 cmichi