-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Linter] Public mut tx context #16878
[Linter] Public mut tx context #16878
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
4 Skipped Deployments
|
external-crates/move/crates/move-compiler/tests/custom_rules/public_mut_tx_context.exp
Outdated
Show resolved
Hide resolved
4f8e7a9
to
48721ac
Compare
@tx-tomcat is attempting to deploy a commit to the Mysten Labs Team on Vercel. A member of the Team first needs to authorize it. |
48721ac
to
282454b
Compare
282454b
to
e9f0265
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments in the PR but I don't quite understand how tests here are split.
This particular lint does not have false negative/positive tests. And I think many of these tests could be condensed down to two files (with an additional one for suppression)
external-crates/move/crates/move-compiler/src/linters/public_mut_tx_context.rs
Outdated
Show resolved
Hide resolved
external-crates/move/crates/move-compiler/tests/linter/correct_public_mut_tx_context.move
Outdated
Show resolved
Hide resolved
external-crates/move/crates/move-compiler/tests/move_check_testsuite.rs
Outdated
Show resolved
Hide resolved
e9f0265
to
839ac30
Compare
839ac30
to
304a8a5
Compare
69410c5
to
069c997
Compare
069c997
to
9b28751
Compare
## Description This linter checks public functions to ensure they use `&mut TxContext` instead of `&TxContext `for better upgradability. Here's a step-by-step breakdown of how to implement this linter: Implement the main logic : `check_function_parameters`: Iterate through function parameters. `is_immutable_tx_context`: Check if a parameter is an immutable `TxContext`. `is_tx_context_type`: Check if a type is `TxContext`. `is_sui_tx_context`: Verify if the type is from the `sui::tx_context` module. ## Test plan Added more use case including false positive, false negative case ## Release notes - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] Indexer: - [ ] JSON-RPC: - [ ] GraphQL: - [X] CLI: Move will now lint against using `&TxContext` instead of `&mut TxContext` in public functions - [ ] Rust SDK: --------- Co-authored-by: jamedzung <dung.dinhnguyen@digitalavenues.com> Co-authored-by: Todd Nowacki <tmn@mystenlabs.com>
Description
This linter checks public functions to ensure they use
&mut TxContext
instead of&TxContext
for better upgradability. Here's a step-by-step breakdown of how to implement this linter:Implement the main logic :
check_function_parameters
: Iterate through function parameters.is_immutable_tx_context
: Check if a parameter is an immutableTxContext
.is_tx_context_type
: Check if a type isTxContext
.is_sui_tx_context
: Verify if the type is from thesui::tx_context
module.Test plan
Added more use case including false positive, false negative case
Release notes
&TxContext
instead of&mut TxContext
in public functions