Skip to content

Commit

Permalink
docs: mark gas-expensive (>= 500 gas units) functions and expressions (
Browse files Browse the repository at this point in the history
  • Loading branch information
novusnota authored Feb 5, 2025
1 parent 4ef078c commit 50612f9
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions dev-docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Improved Chinese localization of the documentation: PR [#1642](https://github.com/tact-lang/tact/pull/1642)
- Removed the notion of the non-standard TL-B syntax `remainder<X>`: PR [#1599](https://github.com/tact-lang/tact/pull/1599)
- Added description of `.boc`, `.ts`, `.abi`, `.pkg` files and completed Compilation page: PR [#1676](https://github.com/tact-lang/tact/pull/1676)
- Marked gas-expensive functions and expressions: PR [#1703](https://github.com/tact-lang/tact/pull/1703)

### Release contributors

Expand Down
4 changes: 4 additions & 0 deletions docs/src/content/docs/book/expressions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ title: Expressions
description: "This page lists all the expressions in Tact"
---

import { Badge } from '@astrojs/starlight/components';

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.

:::note
Expand Down Expand Up @@ -252,6 +254,8 @@ contract ExampleContract {

## `initOf`

<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>

Expression `initOf{:tact}` computes initial state, i.e. `StateInit{:tact}` of a [contract](/book/contracts):

```tact
Expand Down
1 change: 1 addition & 0 deletions docs/src/content/docs/book/maps.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ if (fizz == null) {

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

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

```tact
Expand Down
1 change: 1 addition & 0 deletions docs/src/content/docs/ref/core-advanced.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ Attempts to queue more than $255$ messages throw an exception with an [exit code

## nativeSendMessageReturnForwardFee

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

```tact
Expand Down
10 changes: 10 additions & 0 deletions docs/src/content/docs/ref/core-cells.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ let fizz: Builder = beginCell();

## emptyCell

<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>

```tact
fun emptyCell(): Cell;
```
Expand All @@ -52,6 +54,8 @@ fizz == buzz; // true

## emptySlice

<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>

```tact
fun emptySlice(): Slice;
```
Expand Down Expand Up @@ -128,6 +132,8 @@ A section to group all extension and extension mutation functions for the [`Buil

### Builder.endCell

<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>

```tact
extends fun endCell(self: Builder): Cell;
```
Expand Down Expand Up @@ -1035,6 +1041,8 @@ try {

### Slice.hash

<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>

```tact
extends fun hash(self: Slice): Int;
```
Expand All @@ -1052,6 +1060,8 @@ let fizz: Int = s.hash();

### Slice.asCell

<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>

```tact
extends fun asCell(self: Slice): Cell;
```
Expand Down
12 changes: 12 additions & 0 deletions docs/src/content/docs/ref/core-common.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ title: Common
description: "Commonly used global static functions from the Core library of Tact"
---

import { Badge } from '@astrojs/starlight/components';

List of the most commonly used built-in [global static functions](/book/functions#global-static-functions).

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

### newAddress

<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>

```tact
fun newAddress(chain: Int, hash: Int): Address;
```
Expand Down Expand Up @@ -152,6 +156,8 @@ let oldTonFoundationAddr: Address =

### contractAddress

<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>

```tact
fun contractAddress(s: StateInit): Address;
```
Expand All @@ -166,6 +172,8 @@ let foundMeSome: Address = contractAddress(initOf SomeContract());

### contractAddressExt

<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>

```tact
fun contractAddressExt(chain: Int, code: Cell, data: Cell): Address;
```
Expand Down Expand Up @@ -196,6 +204,8 @@ let hereBeDragons: Address = contractAddressExt(0, initPkg.code, initPkg.data);

### send

<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>

```tact
fun send(params: SendParameters);
```
Expand Down Expand Up @@ -224,6 +234,8 @@ send(SendParameters{

### emit

<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>

```tact
fun emit(body: Cell);
```
Expand Down
6 changes: 6 additions & 0 deletions docs/src/content/docs/ref/core-debug.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ title: Debug
description: "Various debugging functions from the Core library of Tact"
---

import { Badge } from '@astrojs/starlight/components';

List of functions commonly used for debugging smart contracts in Tact.

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

## dump

<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>

```tact
fun dump(arg);
```
Expand Down Expand Up @@ -102,6 +106,8 @@ dump(emit("msg".asComment())); // As emit() function doesn't return a value, dum

## dumpStack

<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>

```tact
fun dumpStack();
```
Expand Down
6 changes: 6 additions & 0 deletions docs/src/content/docs/ref/core-math.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ title: Math
description: "Various math helper functions from the Core library of Tact"
---

import { Badge } from '@astrojs/starlight/components';

Various math helper functions.

## min
Expand Down Expand Up @@ -191,6 +193,8 @@ contract Example {

## checkSignature

<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>

```tact
fun checkSignature(hash: Int, signature: Slice, public_key: Int): Bool;
```
Expand Down Expand Up @@ -232,6 +236,8 @@ contract Showcase {

## checkDataSignature

<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>

```tact
fun checkDataSignature(data: Slice, signature: Slice, public_key: Int): Bool;
```
Expand Down
18 changes: 18 additions & 0 deletions docs/src/content/docs/ref/core-strings.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ title: Strings and StringBuilders
description: "Various String and StringBuilder functions from the Core library of Tact"
---

import { Badge } from '@astrojs/starlight/components';

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.

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

## StringBuilder.toString

<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>

```tact
extends fun toString(self: StringBuilder): String;
```
Expand All @@ -122,6 +126,8 @@ let buzz: String = fizz.toString();

## StringBuilder.toCell

<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>

```tact
extends fun toCell(self: StringBuilder): Cell;
```
Expand All @@ -139,6 +145,8 @@ let buzz: Cell = fizz.toCell();

## StringBuilder.toSlice

<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>

```tact
extends fun toSlice(self: StringBuilder): Slice;
```
Expand Down Expand Up @@ -187,6 +195,8 @@ fizz == buzz; // true, but be careful as it's not always the case

## String.asComment

<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>

```tact
extends fun asComment(self: String): Cell;
```
Expand Down Expand Up @@ -277,6 +287,8 @@ let fizz: Slice = s.fromBase64();

## Int.toString

<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>

```tact
extends fun toString(self: Int): String;
```
Expand All @@ -293,6 +305,8 @@ let fizz: String = (84 - 42).toString();

## Int.toFloatString

<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>

```tact
extends fun toFloatString(self: Int, digits: Int): String;
```
Expand All @@ -311,6 +325,8 @@ let fizz: String = (42).toFloatString(9); // "0.000000042"

## Int.toCoinsString

<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>

```tact
extends fun toCoinsString(self: Int): String;
```
Expand All @@ -333,6 +349,8 @@ fizz == buzz; // true, both store "0.000000042"

## Address.toString

<Badge text="Gas-expensive" title="Uses 500 gas units or more" variant="danger" size="medium"/><p/>

```tact
extends fun toString(self: Address): String;
```
Expand Down

0 comments on commit 50612f9

Please sign in to comment.