Skip to content
This repository was archived by the owner on Dec 12, 2024. It is now read-only.

Commit 82a7a36

Browse files
authored
feat: bounced type constructor description (#235)
1 parent e234dd4 commit 82a7a36

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

pages/book/bounced.mdx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,36 @@ import { Callout } from 'nextra-theme-docs'
22

33
# Bounced messages
44

5-
When a contract sends a message with a flag bounce set to true, then if the message wasn't processed properly, it would bounce back to the sender. This is useful when you want to make sure that the message was processed properly and if not - revert the changes.
5+
When a contract sends a message with a flag `bounce` set to `true{:tact}`, then if the message wasn't processed properly, it would bounce back to the sender. This is useful when you want to make sure that the message was processed properly and if not revert the changes.
66

77
## Caveats
88

9-
Currently in TON bounced messages have only 224 usable data bits in the message and no references. This means that you can't recover much of the data from the bounced message. This is a limitation of the TON blockchain and will be fixed in the future. Tact helps you to check if your message fits the limit and if not - it will suggest to use a special type modifier `bounced<T>` for the receiver that would construct a partial representation that fits into the required limits.
9+
Currently, bounced messages in TON have only 224 usable data bits in the message body and don't have any references. This means that you can't recover much of the data from the bounced message. This is a limitation of the TON blockchain and will be fixed in the future. Tact helps you to check if your message fits the limit and in case it doesn't — suggests using a special type constructor `bounced<T>{:tact}` for the bounced message receiver, that would construct a partial representation of the message that fits into the required limits.
1010

11-
## Bounced messages in Tact
11+
## Bounced message receiver
1212

1313
<Callout type="warning" emoji="⚠️">
14-
Bounced text messages are not supported yet.
14+
15+
Bounced text messages are not supported yet.
16+
1517
</Callout>
1618

17-
To receive a bounced message you need to define a `bounced` receiver in your contract or a trait:
19+
To receive a bounced message, define a `bounced` [receiver function](/book/contracts#receiver-functions) in your [contract](/book/contracts) or a [trait](/book/types#traits):
1820

19-
```tact
21+
```tact {2-4}
2022
contract MyContract {
21-
bounced(src: bounced<MyMessage>) {
23+
bounced(msg: bounced<MyMessage>) {
2224
// ...
2325
}
2426
}
2527
```
2628

27-
To process bounced messages manually, you can use a fallback definition that handles raw `Slice` instead of a message:
29+
To process bounced messages manually, you can use a fallback definition that handles a raw [`Slice{:tact}`](/book/types#primitive-types) directly. Note, that such receiver will get **all** the bounced messages produced by your contract:
2830

29-
```tact
31+
```tact /rawMsg: Slice/
3032
contract MyContract {
31-
bounced(src: Slice) {
33+
bounced(rawMsg: Slice) {
3234
// ...
3335
}
3436
}
35-
```
37+
```

pages/book/types.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ Using individual means of storage often becomes cumbersome, so there are ways to
4444
* [Structs and Messages](#structs-and-messages) — data structures with typed fields.
4545
* [Optionals](#optionals)`null{:tact}` values for variables or fields of [Structs and Messages](#structs-and-messages).
4646

47+
In addition to the composite types above, Tact provides a special type constructor [`bounced<T>{:tact}`](/book/bounced), which can only be specified in [bounced message receivers](/book/bounced).
48+
4749
Note, while [contracts](#contracts) and [traits](#traits) are also considered a part of the Tacts type system, one can't pass them around like [Structs and Messages](#structs-and-messages). Instead, it's possible to obtain the initial state of the given contract by using the [`initOf{:tact}`](/book/expressions#initof) expression.
4850

4951
### Maps

0 commit comments

Comments
 (0)