Skip to content

refactor(stdlib): SendPayGasSeparately -> SendPayFwdFeesSeparately #2483

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

Merged
merged 10 commits into from
Mar 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions dev-docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [fix] Ternary operator with struct and null: PR [#2432](https://github.com/tact-lang/tact/pull/2432)
- [fix] Show an error message for assembly functions with the `get` attribute: PR [#2484](https://github.com/tact-lang/tact/pull/2484)

### Standard Library

- Deprecated the `SendPayGasSeparately` constant in favor of `SendPayFwdFeesSeparately`: PR [#2483](https://github.com/tact-lang/tact/pull/2483)

### Internal infrastructure

- `internalExternalReceiversOutsideMethodsMap` have been reworked to ensure compatibility with explorers: PR [#2398](https://github.com/tact-lang/tact/pull/2398)
@@ -27,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [Daniil Sedov](https://github.com/Gusarich)
- [Novus Nota](https://github.com/novusnota)
- [Petr Makhnev](https://github.com/i582)
- [skywardboundd](https://github.com/skywardboundd)

## [1.6.4] - 2025-03-18

2 changes: 1 addition & 1 deletion docs/grammars/grammar-tact.json
Original file line number Diff line number Diff line change
@@ -295,7 +295,7 @@
},
{
"comment": "Other constants from the core library",
"match": "(?<!\\.)\\b(SendDefaultMode|SendRemainingValue|SendRemainingBalance|SendPayGasSeparately|SendIgnoreErrors|SendBounceIfActionFail|SendDestroyIfZero|SendOnlyEstimateFee|ReserveExact|ReserveAllExcept|ReserveAtMost|ReserveAddOriginalBalance|ReserveInvertSign|ReserveBounceIfActionFail)\\b",
"match": "(?<!\\.)\\b(SendDefaultMode|SendRemainingValue|SendRemainingBalance|SendPayGasSeparately|SendPayFwdFeesSeparately|SendIgnoreErrors|SendBounceIfActionFail|SendDestroyIfZero|SendOnlyEstimateFee|ReserveExact|ReserveAllExcept|ReserveAtMost|ReserveAddOriginalBalance|ReserveInvertSign|ReserveBounceIfActionFail)\\b",
"name": "constant.other.builtin.tact"
},
{
15 changes: 8 additions & 7 deletions docs/src/content/docs/book/message-mode.mdx
Original file line number Diff line number Diff line change
@@ -28,18 +28,19 @@ However, be **very** careful when using `SendRemainingBalance{:tact}`, because i

## Optional flags

Flag value | Constant name | Description
---------: | :------------------------------ | -----------
$+1$ | `SendPayGasSeparately{:tact}` | Pay [forward fees][fwdfee] separately from the message value.
$+2$ | `SendIgnoreErrors{:tact}` | Ignore any errors arising while processing this message during the action phase.
$+16$ | `SendBounceIfActionFail{:tact}` | Bounce the transaction in case of any errors during the action phase. Has no effect if flag $+2$, `SendIgnoreErrors{:tact}`, is used.
$+32$ | `SendDestroyIfZero{:tact}` | The current account (contract) will be destroyed if its resulting balance is zero. This flag is often used with mode $128$, `SendRemainingBalance{:tact}`.
Flag value | Constant name | Description
---------: | :----------------------------------- | -----------
$+1$ | ~~`SendPayGasSeparately{:tact}`~~ | <Badge text="Deprecated since Tact 1.6.5" variant="tip"/><p/> Use `SendPayFwdFeesSeparately{:tact}` instead.
$+1$ | `SendPayFwdFeesSeparately{:tact}` | Pay [forward fees][fwdfee] separately from the message value.
$+2$ | `SendIgnoreErrors{:tact}` | Ignore any errors arising while processing this message during the action phase.
$+16$ | `SendBounceIfActionFail{:tact}` | Bounce the transaction in case of any errors during the action phase. Has no effect if flag $+2$, `SendIgnoreErrors{:tact}`, is used.
$+32$ | `SendDestroyIfZero{:tact}` | The current account (contract) will be destroyed if its resulting balance is zero. This flag is often used with mode $128$, `SendRemainingBalance{:tact}`.

## Combining modes with flags

To create the [`Int{:tact}`][int] value for the `mode` field of `SendParameters{:tact}`, you simply combine a base mode with optional flags using the [bitwise OR](/book/operators#binary-bitwise-or) operation.

For example, if you want to send a regular message and pay transfer fees separately, use the default mode $0$ and add flag $+1$ to obtain `mode = 1`, which is equivalent to using the constant `SendPayGasSeparately{:tact}`.
For example, if you want to send a regular message and pay transfer fees separately, use the default mode $0$ and add flag $+1$ to obtain `mode = 1`, which is equivalent to using the constant `SendPayFwdFeesSeparately{:tact}`.

Alternatively, if you want to send the entire contract balance and destroy it immediately, use mode $128$ and add flag $+32$ to get `mode = 160`, which is equivalent to `SendRemainingBalance | SendDestroyIfZero{:tact}`.

6 changes: 3 additions & 3 deletions docs/src/content/docs/book/send.mdx
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ Field | Type | Description
`body` | [`Cell?{:tact}`][cell] | [Optional][opt] message body as a [`Cell{:tact}`][cell].
`code` | [`Cell?{:tact}`][cell] | [Optional][opt] initial code of the contract (compiled bitcode).
`data` | [`Cell?{:tact}`][cell] | [Optional][opt] initial data of the contract (arguments of the [`init(){:tact}` function](/book/contracts#init-function) or values of [contract parameters](/book/contracts#parameters)).
`value` | [`Int{:tact}`][int] | The amount of [nanoToncoins][nano] you want to send with the message. This value is used to cover [forward fees][fwdfee] unless the optional flag [`SendPayGasSeparately{:tact}`](/book/message-mode#optional-flags) is used.
`value` | [`Int{:tact}`][int] | The amount of [nanoToncoins][nano] you want to send with the message. This value is used to cover [forward fees][fwdfee] unless the optional flag [`SendPayFwdFeesSeparately{:tact}`](/book/message-mode#optional-flags) is used.
`to` | [`Address{:tact}`][p] | Recipient internal [`Address{:tact}`][p] on TON Blockchain.
`bounce` | [`Bool{:tact}`][p] | When set to `true` (default), the message bounces back to the sender if the recipient contract doesn't exist or wasn't able to process the message.

@@ -133,8 +133,8 @@ contract FailureIsNothingButAnotherStep {
// 1st outbound message evaluated and queued (but not yet sent)
send(SendParameters{
to: sender(),
value: ton("0.042"), // plus forward fee due to SendPayGasSeparately
mode: SendIgnoreErrors | SendPayGasSeparately,
value: ton("0.042"), // plus forward fee due to SendPayFwdFeesSeparately
mode: SendIgnoreErrors | SendPayFwdFeesSeparately,
// body is null by default
});

2 changes: 1 addition & 1 deletion docs/src/content/docs/ref/core-send.mdx
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@ Field | Type | Description
:------- | :---------------------------- | :----------
`mode` | [`Int{:tact}`][int] | An 8-bit value that configures how to send a message, defaults to $0$. See: [Message `mode`](/book/message-mode).
`body` | [`Cell?{:tact}`][cell] | [Optional][opt] message body as a [`Cell{:tact}`][cell].
`value` | [`Int{:tact}`][int] | The amount of [nanoToncoins][nano] you want to send with the message. This value is used to cover [forward fees][fwdfee] unless the optional flag [`SendPayGasSeparately{:tact}`](/book/message-mode#optional-flags) is used.
`value` | [`Int{:tact}`][int] | The amount of [nanoToncoins][nano] you want to send with the message. This value is used to cover [forward fees][fwdfee] unless the optional flag [`SendPayFwdFeesSeparately{:tact}`](/book/message-mode#optional-flags) is used.
`bounce` | [`Bool{:tact}`][p] | When set to `true` (default), the message bounces back to the sender if the recipient contract doesn't exist or isn't able to process the message.
`init` | [`StateInit{:tact}`][initpkg] | [Initial package][initpkg] of the contract (initial code and initial data). See: [`initOf{:tact}`][initpkg].

13 changes: 7 additions & 6 deletions docs/src/content/docs/zh-cn/book/message-mode.mdx
Original file line number Diff line number Diff line change
@@ -20,17 +20,18 @@ import { Badge } from '@astrojs/starlight/components';
## 可选标记 {#optional-flags}

| 标志值 | 常量名称 | 说明 |
| ---------: | :------------------------------ | ---------------------------------------------------------------------- |
| $+1$ | `SendPayGasSeparately{:tact}` | 将转发费用与消息价值分开支付。 |
| $+2$ | `SendIgnoreErrors{:tact}` | 忽略行动阶段处理该消息时出现的任何错误。 |
| $+16$ | `SendBounceIfActionFail{:tact}` | 如果在行动阶段出现任何错误,则退回交易。 如果使用了标志 $+2$, `SendIgnoreErrors{:tact}`,则没有影响。 |
| $+32$ | `SendDestroyIfZero{:tact}` | 如果当前账户的余额为零,则必须销毁该账户(通常与模式 $128$, `SendRemainingBalance{:tact}` 一起使用)。 |
| ---------: | :---------------------------------- | ---------------------------------------------------------------------- |
| $+1$ | ~~`SendPayGasSeparately{:tact}`~~ | 将转发费用与消息价值分开支付。 |
| $+1$ | `SendPayFwdFeesSeparately{:tact}` | 自 Tact 1.6.5 起已弃用 将转发费用与消息价值分开支付。 |
| $+2$ | `SendIgnoreErrors{:tact}` | 忽略行动阶段处理该消息时出现的任何错误。 |
| $+16$ | `SendBounceIfActionFail{:tact}` | 如果在行动阶段出现任何错误,则退回交易。 如果使用了标志 $+2$, `SendIgnoreErrors{:tact}`,则没有影响。 |
| $+32$ | `SendDestroyIfZero{:tact}` | 如果当前账户的余额为零,则必须销毁该账户(通常与模式 $128$, `SendRemainingBalance{:tact}` 一起使用)。 |

## 将模式与标志(flags)相结合 {#combining-modes-with-flags}

要为 `SendParameters{:tact}` 的 `mode` 字段创建 [`Int{:tact}`][int] 值,只需通过 [bitwise OR](/zh-cn/book/operators#binary-bitwise-or) 运算将基本模式与可选标记结合起来。

例如,如果您想分别发送普通消息和支付转账费用,请使用模式 $0$(默认)和标志 $+1$,以获得 `mode` $= 1$,这等同于使用 `SendPayGasSeparately{:tact}` 常量。
例如,如果您想分别发送普通消息和支付转账费用,请使用模式 $0$(默认)和标志 $+1$,以获得 `mode` $= 1$,这等同于使用 `SendPayFwdFeesSeparately{:tact}` 常量。

或者,如果要发送全部合约余额并立即销毁,使用模式 $128$ 和标志 $+32$,得到 `mode` $= 160$,相当于 `SendRemainingBalance | SendDestroyIfZero{:tact}` 常量。

6 changes: 3 additions & 3 deletions docs/src/content/docs/zh-cn/book/send.mdx
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ Tact 中的消息通常使用内置[Struct](/zh-cn/book/structs-and-messages#str
| :------- | :--------------------- | :---------------------------------------------------------------------------------------------------------------------------------- |
| `bounce` | [`Bool{:tact}`][p] | 如果设置为`true`(默认),当接收合约不存在或无法处理消息时,消息会退回给发送者。 |
| `to` | [`Address{:tact}`][p] | TON 区块链中的内部接收器 [`Address{:tact}`][p]。 |
| `value` | [`Int{:tact}`][int] | 消息中要发送的[nanoToncoins][nano]的金额。 此值通常用于支付[转发费用][fwdfee],除非使用了可选标志[`SendPayGasSeparately{:tact}`](/zh-cn/book/message-mode#optional-flags)。 |
| `value` | [`Int{:tact}`][int] | 消息中要发送的[nanoToncoins][nano]的金额。 此值通常用于支付[转发费用][fwdfee],除非使用了可选标志[`SendPayFwdFeesSeparately{:tact}`](/zh-cn/book/message-mode#optional-flags)。 |
| `mode` | [`Int{:tact}`][int] | 一个 8 位值,用于配置发送消息的方式,默认值为 $0$。 参见:[消息`模式`](/zh-cn/book/message-mode)。 见:[消息`mode`](/zh-cn/book/message-mode). |
| `body` | [`Cell?{:tact}`][cell] | [可选][opt]消息正文作为[`Cell{:tact}`][cell] |
| `code` | [`Cell?{:tact}`][cell] | [可选][opt] 合约的初始代码(编译后的字节码) |
@@ -110,8 +110,8 @@ contract FailureIsNothingButAnotherStep {
// 1st outbound message evaluated and queued (but not sent yet)
send(SendParameters{
to: sender(),
value: ton("0.042"), // plus forward fee due to SendPayGasSeparately
mode: SendIgnoreErrors | SendPayGasSeparately,
value: ton("0.042"), // plus forward fee due to SendPayFwdFeesSeparately
mode: SendIgnoreErrors | SendPayFwdFeesSeparately,
});

// 2nd outbound message evaluated and queued (but not sent yet, and never will be!)
3 changes: 2 additions & 1 deletion spell/cspell-list.txt
Original file line number Diff line number Diff line change
@@ -159,7 +159,8 @@ seti
shardchains
shiki
Shvetc
Stateinit
skywardboundd
Stateinit
statinit
stdlib
stdlibs
4 changes: 2 additions & 2 deletions src/benchmarks/contracts/escrow.tact
Original file line number Diff line number Diff line change
@@ -125,7 +125,7 @@ contract Escrow (
message(MessageParameters{
to: self.sellerAddress,
value: self.dealAmount - royaltyAmount,
mode: SendPayGasSeparately
mode: SendPayFwdFeesSeparately
}
);
message(MessageParameters{
@@ -136,7 +136,7 @@ contract Escrow (
);
} else {
throwUnless(404, ctx.value > (2 * self.JETTON_TRANSFER_GAS));
self.sendJettons(self.sellerAddress, self.dealAmount - royaltyAmount, SendPayGasSeparately);
self.sendJettons(self.sellerAddress, self.dealAmount - royaltyAmount, SendPayFwdFeesSeparately);
self.sendJettons(self.guarantorAddress, royaltyAmount, SendRemainingBalance | SendDestroyIfZero);
}
}
2 changes: 1 addition & 1 deletion src/benchmarks/contracts/jetton-wallet-notcoin.tact
Original file line number Diff line number Diff line change
@@ -86,7 +86,7 @@ contract JettonWalletNotcoin(
message(MessageParameters{
to: self.owner,
value: msg.forwardTonAmount,
mode: SendPayGasSeparately,
mode: SendPayFwdFeesSeparately,
bounce: false,
body: JettonNotification{ // 0x7362d09c -- Remind the new Owner
queryId: msg.queryId,
2 changes: 1 addition & 1 deletion src/benchmarks/contracts/jetton-wallet.tact
Original file line number Diff line number Diff line change
@@ -65,7 +65,7 @@ contract JettonWallet(
message(MessageParameters{
to: self.owner,
value: msg.forwardTonAmount,
mode: SendPayGasSeparately,
mode: SendPayFwdFeesSeparately,
bounce: false,
body: JettonNotification{ // 0x7362d09c -- Remind the new Owner
queryId: msg.queryId,
Loading