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

docs: clarify interactions of message sending functions and their modes #1634

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

novusnota
Copy link
Member

Also listed functions with implicit mode, plus made some minor fixes on related pages

Issue

Closes #1093.

Checklist

  • I have updated CHANGELOG.md
  • I have run the linter, formatter and spellchecker
  • I did not do unrelated and/or undiscussed refactorings

Also listed functions with implicit mode, plus made some minor fixes on
related pages
@novusnota novusnota added this to the Doc: 2025-01 milestone Jan 30, 2025
@novusnota novusnota requested a review from a team as a code owner January 30, 2025 01:20

:::note

To avoid dealing with similar cases and to simplify future [debugging sessions](/book/debug), consider having only one call to one of the [message sending functions](#message-sending-functions) per [receiver function](/book/receive), preferably at the end of the function body.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should suggest a different solution based on nativeReserve here. @Shvandre can you please help with this part

Copy link
Contributor

@Shvandre Shvandre Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this specific case (when contract initially has 0 on balance). Such code will work properly

send(SendParameters{
    bounce: false,
    body: "TEST1".asComment(),
    to: sender(), //Actually any address
    value: ton("0.5"),
    mode: SendDefaultMode,
});

send(SendParameters{
    bounce: false,
    body: "TEST2".asComment(),
    to: myAddress(), //Actually any address
    value: 0,
    mode: SendRemainingBalance,
});

And nativeReserve is unnecessary here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point is in bounce: false and using SendRemainingBalance instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, bounce does not affect anything.
Point is that SendRemainingBalance works correctly, taking previous actions into account,
while SendRemainingValue does not

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! super-useful, thanks Andrei

let's add a solution what to do when the balance is not zero

Copy link
Member Author

@novusnota novusnota Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, and I'll also add info on SendRemainingValue vs. SendRemainingBalance to the book/message-mode, under the table in "Base modes" section

docs/src/content/docs/ref/core-common.mdx Outdated Show resolved Hide resolved
Co-authored-by: Anton Trunov <anton@tonstudio.io>
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 this pull request may close these issues.

Clarify SendRemainingValue applies when first message is emit
3 participants