[#2084] Add attribute for TZIP-16 compatibility
Motivation and Context
In LSP we want to have diagnostics containing TZIP-16 warnings. Since those work on-the-fly, we need a way to track storages that the user considers TZIP-16 compatible.
The simplest way to do so is to add the dedicated attribute/decorator.
Pros:
- Easy to implement. If we compare this to options where "marked as TZIP-16" is remembered in memory - in those options the marker will be hard to track in the presence of code edits.
- Information about TZIP-16 compliant storages persists across coding session, so is more reliable as a testing tool.
Cons:
- Kinda pollutes the source code.
- Running all checks on IDE startup may take long since they involve downloading data (metadata can refer to external sources).
- At the moment, is not supported by the compiler, which may cause an impression of inconsistency in the ecosystem.
Description
So this MR makes LIGO compiler aware of the tzip16_compatible
attribute and mentions it in the LIGO documentation.
We can consider different names for the attribute, e.g. tzip16_compliant
may be better than the current variant.
Component
-
compiler -
website -
webide -
vscode-plugin -
debugger
Types of changes
-
Bug fix (non-breaking change which fixes an issue) -
New feature (non-breaking change which adds functionality) -
Breaking change (fix or feature that would cause existing functionality to not work as expected) -
Performance improvement (non-breaking change that improves performance) -
None (change with no changelog)
Changelog
Added tzip16_compatible
attribute for indicating that the given storage value is expected to satisfy TZIP-16 metadata rules.
This attribute does nothing on itself at the moment, but some IDEs may provide additional verification.
Example (CameLIGO):
type storage =
{
data : int;
metadata : (string, bytes) big_map
}
[@tzip16_compatible]
let storage_sample : storage =
{
data = 5;
metadata =
Big_map.literal
[
("",
[%bytes
"https://ipfs.io/ipfs/QmSBc8QuynU7bArUGtjwCRhZUbJyZQArrczKnqM7hZPtfV"])
]
}
Example (JsLIGO):
type storage = { data: int; metadata: big_map<string, bytes> }
@tzip16_compatible
const storage_sample: storage = {
data: 5,
metadata: Big_map.literal(
list(
[
[
"",
(
bytes
`https://ipfs.io/ipfs/QmSBc8QuynU7bArUGtjwCRhZUbJyZQArrczKnqM7hZPtfV`
)
]
]
)
)
}
Checklist:
-
If a new syntax has been introduced, put a message on slack ligo-lsp -
Changes follow the existing coding style (use dune @fmt
to check). -
Tests for the changes have been added (for bug fixes / feature). -
Documentation has been updated. -
Changelog description has been added (if appropriate). -
Start titles under ## Changelog
section with #### (if appropriate). -
There is no image or uploaded file in changelog -
Examples in changed behaviour have been added to the changelog (for breaking change / feature).
Edited by Konstantin Ivanov