Skip to content
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

SendParameters: Constant for mode: 0 #988

Closed
Esorat opened this issue Oct 25, 2024 · 3 comments · Fixed by #1010
Closed

SendParameters: Constant for mode: 0 #988

Esorat opened this issue Oct 25, 2024 · 3 comments · Fixed by #1010

Comments

@Esorat
Copy link
Contributor

Esorat commented Oct 25, 2024

We can define a constant for the 0 mode value to improve readability and describe the default behavior more clearly. This constant will replace any direct usage of 0 in the mode field throughout the codebase, as commonly seen in real-world contracts.
This change will make choosing the default mode more explicit and could be leveraged by SuspiciousMessageMode, which detects such cases: nowarp/misti#199.

Context: https://docs.tact-lang.org/book/message-mode/

@anton-trunov
Copy link
Member

The mode field has 0 as the default value, so people often don't even mention it, like code and data if they don't want to deploy a contract.

struct SendParameters {
    bounce: Bool = true;
    to: Address;
    value: Int;
    mode: Int = 0;
    body: Cell? = null;
    code: Cell? = null;
    data: Cell? = null;
}

@jubnzv
Copy link
Member

jubnzv commented Oct 26, 2024

@anton-trunov We have seen many cases in real-world contracts where people simply write mode: 0. It seems they are either trying to explicitly specify the mode or are unsure about the default value.

Should we just ignore these cases or raise warnings asking them to remove the mode parameter?

@anton-trunov
Copy link
Member

We can add const SendDefaultMode: Int = 0; (or SendDefaultMode) to send.tact for the sake of completeness

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants