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

Commit 17176cb

Browse files
authored
feat: Overhaul of Message modes page (#74)
* fix: Remove warnings from `theme.config.jsx` And clean-up it a bit. See: https://nextra.site/docs/docs-theme/theme-configuration#dark-mode-and-themes * chore: Adding license field, CC BY 4.0 In accordance to the license used in tact-docs, and the valid SPDX license expression for it — CC-BY-4.0. See: * https://spdx.org/licenses/ * https://spdx.org/licenses/CC-BY-4.0.html * https://creativecommons.org/licenses/by/4.0/ * feat: Overhaul of `Message modes` page And couple of small warning fixes Fix #58
1 parent 17eb9fb commit 17176cb

File tree

7 files changed

+67
-65
lines changed

7 files changed

+67
-65
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
node_modules
33
out
44
package-lock.json
5+
yarn-error.log

Diff for: package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
"devDependencies": {
1818
"@types/node": "^18.11.19",
1919
"typescript": "^4.9.5"
20-
}
21-
}
20+
},
21+
"license": "CC-BY-4.0"
22+
}

Diff for: pages/language/guides/_meta.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"bounced": "Bounced Messages",
88
"external": "External Messages",
99
"lifecycle": "Message lifecycle",
10-
"send": "Send messages",
10+
"send": "Sending messages",
11+
"message-mode": "Message mode",
1112
"deploy": "Deploy contracts",
1213
"debug": "Debugging",
1314
"upgrades": "Contract upgrades",

Diff for: pages/language/guides/message-mode.mdx

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { Callout } from 'nextra/components'
2+
3+
# Message `mode`
4+
5+
As you might've noticed, messages are sent with the `mode` param of a struct `SendParameters`. It's an Int value, which is combined from base modes and optional flags, which are also Int values.
6+
7+
It's possible to use raw Int values and manually provide them for the `mode`, but for your convenience there's a set of constants which you may use to construct the compound `mode` with ease. Take a look at the following tables for more information on base modes and optional flags.
8+
9+
## Base modes
10+
11+
Mode value | Constant name | Description
12+
---------: | :------------------- | -----------------------------------------------------------------------------------------------------------------------
13+
$0$ | - | Ordinary message (default).
14+
$64$ | SendRemainingValue | Carry all the remaining value of the inbound message in addition to the value initially indicated in the new message.
15+
$128$ | SendRemainingBalance | Carry all the remaining balance of the current smart contract instead of the value originally indicated in the message.
16+
17+
## Optional flags
18+
19+
Flag value | Constant name | Description
20+
---------: | :--------------------- | ----------------------------------------------------------------------------------------------------------------------
21+
$+1$ | SendPayGasSeparately | Pay forward fees separately from the message value.
22+
$+2$ | SendIgnoreErrors | Ignore any errors arising while processing this message during the action phase.
23+
$+16$ | SendBounceIfActionFail | Bounce transaction in case of any errors during action phase. Has no effect if flag $+2$, SendIgnoreErrors is used.
24+
$+32$ | SendDestroyIfZero | Current account must be destroyed if its resulting balance is zero (often used with mode $128$, SendRemainingBalance).
25+
26+
## Combining modes with flags
27+
28+
To make the Int value for `mode` field of SendParameters, you just have to combine base modes with optional flags by adding them together as numbers.
29+
30+
For example, if you want to send a regular message and pay transfer fees separately, use the mode $0$ (default) and a flag $+1$ to get `mode` $= 1$, which is equal to just use SendPayGasSeparately constant.
31+
32+
Alternatively, if you want to send the whole contract balance and destroy it immediately, use the mode $128$ and flag $+32$ to get `mode` $= 160$, which is equal to SendRemainingBalance + SendDestroyIfZero.
33+
34+
Here's how the latter example would look in code:
35+
36+
```tact
37+
let to: Address = ...;
38+
let value: Int = ton("1");
39+
send(SendParameters{
40+
to: to,
41+
value: value,
42+
mode: SendRemainingBalance + SendDestroyIfZero,
43+
body: "Hello, World!".asComment()
44+
});
45+
```
46+
47+
<Callout>
48+
NOTE: There can be only one base mode, but number of optional flags may vary: you can use them all, none or just some.
49+
</Callout>

Diff for: pages/language/ref/_meta.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44
"random": "Random",
55
"math": "Math",
66
"cells": "Cells, Builders and Slices",
7-
"message-modes": "Message modes",
87
"advanced": "Advanced"
9-
}
8+
}

Diff for: pages/language/ref/message-modes.mdx

-35
This file was deleted.

Diff for: theme.config.jsx

+11-25
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ export default {
2121
<path fillRule="evenodd" clipRule="evenodd" d="M2.89671 31.4666L13.5452 19.7152L3.50521 15.7065L28.99 1.0932C26.5378 -2.74133e-09 23.0142 0 17 0C9.73879 0 6.10818 0 3.61017 1.92391C2.97777 2.41098 2.41098 2.97777 1.92391 3.61017C0 6.10818 0 9.73879 0 17C0 24.2612 0 27.8918 1.92391 30.3898C2.21981 30.774 2.54513 31.134 2.89671 31.4666ZM4.39128 32.5948C6.86599 34 10.4607 34 17 34C24.2612 34 27.8918 34 30.3898 32.0761C31.0222 31.589 31.589 31.0222 32.0761 30.3898C34 27.8918 34 24.2612 34 17C34 9.73879 34 6.10818 32.0761 3.61017C31.6542 3.06237 31.1725 2.56381 30.6401 2.12364L20.2292 13.6125L30.807 18.159L4.39128 32.5948Z" fill="currentColor" />
2222
</svg>
2323
),
24-
defaultTheme: 'dark',
24+
nextThemes: {
25+
defaultTheme: 'dark',
26+
},
2527
project: {
2628
link: 'https://github.com/tact-lang/tact-docs',
2729
},
@@ -43,31 +45,15 @@ export default {
4345
<>
4446
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
4547

46-
<meta
47-
name="description"
48-
content="Tact Language Documentation"
49-
/>
48+
<meta name="description" content="Tact Language Documentation" />
49+
50+
<meta name="og:title" content="Tact Language Documentation" />
51+
52+
<meta name="og:description" content="Language reference and guides for Tact" />
5053

51-
<meta
52-
name="og:title"
53-
content="Tact Language Documentation"
54-
/>
55-
<meta
56-
name="og:description"
57-
content="Language reference and guides for Tact"
58-
/>
54+
<meta name="twitter:card" content="summary_large_image" />
5955

60-
<meta
61-
name="twitter:card"
62-
content="summary_large_image"
63-
/>
64-
65-
<meta
66-
name="twitter:site"
67-
content="@tact_language
68-
">
69-
70-
</meta>
56+
<meta name="twitter:site" content="@tact_language" />
7157

7258
<meta name="apple-mobile-web-app-title" content="Tact" />
7359

@@ -86,4 +72,4 @@ export default {
8672
/>;
8773
</>
8874
)
89-
}
75+
}

0 commit comments

Comments
 (0)