[TM-337] Use safe migrations
Description
Problem: they are not used yet.
Solution: use them in upgradeable contract template and in samples.
We still allow manual migrations because migrations consisting of multiple stages (for the sake of fitting into gas limit) are not supported yet.
Also in this commit I had to make MigrationScript
, as well as
ContractCode
, a newtype wrapper for the sake of HasTypeDoc
instance.
What remains for future work (these changes are problematic to do at the current stage):
- Make
Parameter
type of upgradeable contract know storage type. - Make
ContractCode
know storage type. - Make
MigrationScript
know old/new storage types. - Consider using more safe coercions for
UContractRouter
andMigrationScript
(e.g. only coercion betweenUContractRouter
andSomeUContractRouter
should be allowed, not between twoUContractRouter
s).
After these changes it won't be possible to accidentially apply migration to wrong version of a contract.
Related issue(s)
https://issues.serokell.io/issue/TM-337
✅ Checklist for your Merge Request
Related changes (conditional)
-
Tests (see short guidelines)
-
If I added new functionality, I added tests covering it. -
If I fixed a bug, I added a regression test to prevent the bug from silently reappearing again.
-
-
Documentation
Stylistic guide (mandatory)
-
My commits comply with the following policy. -
My code complies with the style guide.
Edited by Konstantin Ivanov