You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The #[ink(topic)] annotation enables third party tooling to filter for "topics" ‒ discrete events for which it makes sense to filter. Typical examples where this can make sense are AccountId, bool or enum variants.
It typically doesn't make sense to annotate types like u32 or i32 as a topic, if those fields can take continuous values that could be anywhere between ::MIN and ::MAX. An example of a case where it doesn't make sense at all to have a topic on the storage field is something like value: Balance.
We should provide a linter rule that warns developers when they annotate a number primitive with #[ink(topic)].
The text was updated successfully, but these errors were encountered:
I'm putting some notes here on how to approach this issue:
The linting stage in ink! is optional by now. You have to install the linting dependencies and can then execute cargo contract build --lint on a contract. With the ink! 4.0 release we deprecated the only one lint we had. So at the moment there won't be any lint run.
A lint was introduced in this PR. The files to get you started are in ink_linting/src/. Those two are most relevant:
…1837)
* The initial structure of the linting crate and tests
Needed for #1436
* Implement the lint that checks primitive numeric types in expanded code
* The initial implementation of the `primitive_topic` lint
* chore: Run clippy
* fix(fmt)
* fix: Lint suppressions
The problem with suppressions is that `rustc` saves the state of the
last visited node and checks its attributes to decide if the lint
warning should be suppressed there (see:
[LateContext::last_node_with_lint_attrs](https://github.com/rust-lang/rust/blob/c44324a4fe8e96f9d6473255df6c3a481caca76f/compiler/rustc_lint/src/context.rs#L1105)).
This commit adds a call to the utility function from clippy that checks
if the lint is suppressed for the field definition node, not for the
last node (which is `Topics` impl).
* chore: cleanup
* chore: make warning messages more consistent
* feat: support events 2.0
Rework the lint after #1827 is merged
* chore: Fix comments; remove needless empty file
* chore: Update `clippy_utils` version
* fix: Cargo.toml
---------
Co-authored-by: Georgiy Komarov <georgiy@parity.io>
The
#[ink(topic)]
annotation enables third party tooling to filter for "topics" ‒ discrete events for which it makes sense to filter. Typical examples where this can make sense areAccountId
,bool
orenum
variants.It typically doesn't make sense to annotate types like
u32
ori32
as a topic, if those fields can take continuous values that could be anywhere between::MIN
and::MAX
. An example of a case where it doesn't make sense at all to have a topic on the storage field is something likevalue: Balance
.We should provide a linter rule that warns developers when they annotate a number primitive with
#[ink(topic)]
.The text was updated successfully, but these errors were encountered: