Skip to content

Commit a3f7e46

Browse files
novusnotasansx
authored andcommitted
docs: mark gas-expensive (>= 500 gas units) functions and expressions (tact-lang#1703)
1 parent b95522e commit a3f7e46

9 files changed

+59
-0
lines changed

dev-docs/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
112112
- Improved Chinese localization of the documentation: PR [#1642](https://github.com/tact-lang/tact/pull/1642)
113113
- Removed the notion of the non-standard TL-B syntax `remainder<X>`: PR [#1599](https://github.com/tact-lang/tact/pull/1599)
114114
- Added description of `.boc`, `.ts`, `.abi`, `.pkg` files and completed Compilation page: PR [#1676](https://github.com/tact-lang/tact/pull/1676)
115+
- Marked gas-expensive functions and expressions: PR [#1703](https://github.com/tact-lang/tact/pull/1703)
115116

116117
### Release contributors
117118

docs/src/content/docs/book/expressions.mdx

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ title: Expressions
33
description: "This page lists all the expressions in Tact"
44
---
55

6+
import { Badge } from '@astrojs/starlight/components';
7+
68
Every operator in Tact forms an expression, but there's much more to uncover as Tact offers a wide range of expressive options to choose from.
79

810
:::note
@@ -252,6 +254,8 @@ contract ExampleContract {
252254

253255
## `initOf`
254256

257+
<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>
258+
255259
Expression `initOf{:tact}` computes initial state, i.e. `StateInit{:tact}` of a [contract](/book/contracts):
256260

257261
```tact

docs/src/content/docs/book/maps.mdx

+1
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ if (fizz == null) {
359359

360360
### Compare with `.deepEquals()` {#deepequals}
361361

362+
<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/>
362363
<Badge text="Available since Tact 1.5" variant="tip" size="medium"/><p/>
363364

364365
```tact

docs/src/content/docs/ref/core-advanced.mdx

+1
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ Attempts to queue more than $255$ messages throw an exception with an [exit code
444444

445445
## nativeSendMessageReturnForwardFee
446446

447+
<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/>
447448
<Badge text="Available since Tact 1.5" variant="tip" size="medium"/><p/>
448449

449450
```tact

docs/src/content/docs/ref/core-cells.mdx

+10
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ let fizz: Builder = beginCell();
3535

3636
## emptyCell
3737

38+
<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>
39+
3840
```tact
3941
fun emptyCell(): Cell;
4042
```
@@ -52,6 +54,8 @@ fizz == buzz; // true
5254

5355
## emptySlice
5456

57+
<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>
58+
5559
```tact
5660
fun emptySlice(): Slice;
5761
```
@@ -128,6 +132,8 @@ A section to group all extension and extension mutation functions for the [`Buil
128132

129133
### Builder.endCell
130134

135+
<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>
136+
131137
```tact
132138
extends fun endCell(self: Builder): Cell;
133139
```
@@ -1035,6 +1041,8 @@ try {
10351041

10361042
### Slice.hash
10371043

1044+
<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>
1045+
10381046
```tact
10391047
extends fun hash(self: Slice): Int;
10401048
```
@@ -1052,6 +1060,8 @@ let fizz: Int = s.hash();
10521060

10531061
### Slice.asCell
10541062

1063+
<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>
1064+
10551065
```tact
10561066
extends fun asCell(self: Slice): Cell;
10571067
```

docs/src/content/docs/ref/core-common.mdx

+12
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ title: Common
33
description: "Commonly used global static functions from the Core library of Tact"
44
---
55

6+
import { Badge } from '@astrojs/starlight/components';
7+
68
List of the most commonly used built-in [global static functions](/book/functions#global-static-functions).
79

810
## Contextual
@@ -117,6 +119,8 @@ require(ctx.value != 68 + 1, "Invalid amount of nanoToncoins, bye!");
117119

118120
### newAddress
119121

122+
<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>
123+
120124
```tact
121125
fun newAddress(chain: Int, hash: Int): Address;
122126
```
@@ -152,6 +156,8 @@ let oldTonFoundationAddr: Address =
152156

153157
### contractAddress
154158

159+
<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>
160+
155161
```tact
156162
fun contractAddress(s: StateInit): Address;
157163
```
@@ -166,6 +172,8 @@ let foundMeSome: Address = contractAddress(initOf SomeContract());
166172

167173
### contractAddressExt
168174

175+
<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>
176+
169177
```tact
170178
fun contractAddressExt(chain: Int, code: Cell, data: Cell): Address;
171179
```
@@ -196,6 +204,8 @@ let hereBeDragons: Address = contractAddressExt(0, initPkg.code, initPkg.data);
196204

197205
### send
198206

207+
<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>
208+
199209
```tact
200210
fun send(params: SendParameters);
201211
```
@@ -224,6 +234,8 @@ send(SendParameters{
224234

225235
### emit
226236

237+
<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>
238+
227239
```tact
228240
fun emit(body: Cell);
229241
```

docs/src/content/docs/ref/core-debug.mdx

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ title: Debug
33
description: "Various debugging functions from the Core library of Tact"
44
---
55

6+
import { Badge } from '@astrojs/starlight/components';
7+
68
List of functions commonly used for debugging smart contracts in Tact.
79

810
Read more about debugging on the dedicated page: [Debugging](/book/debug).
@@ -40,6 +42,8 @@ try {
4042

4143
## dump
4244

45+
<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>
46+
4347
```tact
4448
fun dump(arg);
4549
```
@@ -102,6 +106,8 @@ dump(emit("msg".asComment())); // As emit() function doesn't return a value, dum
102106

103107
## dumpStack
104108

109+
<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>
110+
105111
```tact
106112
fun dumpStack();
107113
```

docs/src/content/docs/ref/core-math.mdx

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ title: Math
33
description: "Various math helper functions from the Core library of Tact"
44
---
55

6+
import { Badge } from '@astrojs/starlight/components';
7+
68
Various math helper functions.
79

810
## min
@@ -191,6 +193,8 @@ contract Example {
191193

192194
## checkSignature
193195

196+
<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>
197+
194198
```tact
195199
fun checkSignature(hash: Int, signature: Slice, public_key: Int): Bool;
196200
```
@@ -232,6 +236,8 @@ contract Showcase {
232236

233237
## checkDataSignature
234238

239+
<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>
240+
235241
```tact
236242
fun checkDataSignature(data: Slice, signature: Slice, public_key: Int): Bool;
237243
```

docs/src/content/docs/ref/core-strings.mdx

+18
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ title: Strings and StringBuilders
33
description: "Various String and StringBuilder functions from the Core library of Tact"
44
---
55

6+
import { Badge } from '@astrojs/starlight/components';
7+
68
Strings are immutable sequences of characters, which means that once a [`String{:tact}`][p] is created, it cannot be changed. Strings are useful to store text, and so they can be converted to [`Cell{:tact}`][cell] type to be used as message bodies.
79

810
To be able to concatenate strings in a gas-efficient way, use a [`StringBuilder{:tact}`][p].
@@ -105,6 +107,8 @@ let fizz: StringBuilder = beginString()
105107

106108
## StringBuilder.toString
107109

110+
<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>
111+
108112
```tact
109113
extends fun toString(self: StringBuilder): String;
110114
```
@@ -122,6 +126,8 @@ let buzz: String = fizz.toString();
122126

123127
## StringBuilder.toCell
124128

129+
<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>
130+
125131
```tact
126132
extends fun toCell(self: StringBuilder): Cell;
127133
```
@@ -139,6 +145,8 @@ let buzz: Cell = fizz.toCell();
139145

140146
## StringBuilder.toSlice
141147

148+
<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>
149+
142150
```tact
143151
extends fun toSlice(self: StringBuilder): Slice;
144152
```
@@ -187,6 +195,8 @@ fizz == buzz; // true, but be careful as it's not always the case
187195

188196
## String.asComment
189197

198+
<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>
199+
190200
```tact
191201
extends fun asComment(self: String): Cell;
192202
```
@@ -277,6 +287,8 @@ let fizz: Slice = s.fromBase64();
277287

278288
## Int.toString
279289

290+
<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>
291+
280292
```tact
281293
extends fun toString(self: Int): String;
282294
```
@@ -293,6 +305,8 @@ let fizz: String = (84 - 42).toString();
293305

294306
## Int.toFloatString
295307

308+
<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>
309+
296310
```tact
297311
extends fun toFloatString(self: Int, digits: Int): String;
298312
```
@@ -311,6 +325,8 @@ let fizz: String = (42).toFloatString(9); // "0.000000042"
311325

312326
## Int.toCoinsString
313327

328+
<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>
329+
314330
```tact
315331
extends fun toCoinsString(self: Int): String;
316332
```
@@ -333,6 +349,8 @@ fizz == buzz; // true, both store "0.000000042"
333349

334350
## Address.toString
335351

352+
<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>
353+
336354
```tact
337355
extends fun toString(self: Address): String;
338356
```

0 commit comments

Comments
 (0)