Skip to content
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

feat(docs): new functions from TVM upgrades 2023-07 and 2024-04 #1062

Merged
merged 4 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions .github/workflows/tact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Node.js 18 for backwards compat tests
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18
# without caching
Expand All @@ -46,7 +46,7 @@ jobs:
yarn config delete ignore-engines
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Wider range of serialization options for integers — `uint1` through `uint256` and `int1` through `int257`: PR [#558](https://github.com/tact-lang/tact/pull/558), PR [#937](https://github.com/tact-lang/tact/pull/937)
- The `deepEquals` method for the `Map` type: PR [#637](https://github.com/tact-lang/tact/pull/637), PR [#939](https://github.com/tact-lang/tact/pull/939)
- `asm` bodies for module-level functions: PR [#769](https://github.com/tact-lang/tact/pull/769), PR [#825](https://github.com/tact-lang/tact/pull/825)
- Corresponding stdlib functions for new TVM instructions from 2023.07 and 2024.04 upgrades: PR [#331](https://github.com/tact-lang/tact/pull/331). Added the `storeBuilder` extension function and `gasConsumed`, `getComputeFee`, `getStorageFee`, `getForwardFee`, `getSimpleComputeFee`, `getSimpleForwardFee`, `getOriginalFwdFee`, `myStorageDue` functions.
- Corresponding stdlib functions for new TVM instructions from 2023.07 and 2024.04 upgrades: PR [#331](https://github.com/tact-lang/tact/pull/331), PR [#1062](https://github.com/tact-lang/tact/pull/1062). Added the `storeBuilder` extension function and `gasConsumed`, `getComputeFee`, `getStorageFee`, `getForwardFee`, `getSimpleComputeFee`, `getSimpleForwardFee`, `getOriginalFwdFee`, `myStorageDue` functions.
- `slice`, `rawSlice`, `ascii` and `crc32` built-in functions: PR [#787](https://github.com/tact-lang/tact/pull/787), PR [#799](https://github.com/tact-lang/tact/pull/799), PR [#951](https://github.com/tact-lang/tact/pull/951)
- `Builder.storeMaybeRef`, `parseStdAddress` and `parseVarAddress` stdlib functions: PR [#793](https://github.com/tact-lang/tact/pull/793), PR [#950](https://github.com/tact-lang/tact/pull/950)
- The compiler development guide: PR [#833](https://github.com/tact-lang/tact/pull/833)
Expand Down
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"funs",
"frontmatter",
"Georgiy",
"getsimpleforwardfee",
"gettest",
"Héctor",
"infixl",
Expand Down
4 changes: 2 additions & 2 deletions docs/src/content/docs/book/debug.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ If you're overwhelmed by the testing setup of [Blueprint][bp] or just want to te
```json filename="package.json" {3}
{
"scripts": {
"lab": "blueprint build 1>/dev/null && yarn test -t plays"
"lab": "blueprint build --all 1>/dev/null && yarn test -t plays"
}
}
```
Expand All @@ -703,7 +703,7 @@ If you're overwhelmed by the testing setup of [Blueprint][bp] or just want to te
```json filename="package.json" {3-4}
{
"scripts": {
"build": "blueprint build | out-null",
"build": "blueprint build --all | out-null",
"lab": "yarn build && yarn test -t plays"
}
}
Expand Down
41 changes: 17 additions & 24 deletions docs/src/content/docs/book/security-best-practices.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ message Sample {
parsedField: Slice;
}

receive(msg: Sample) {
// Process msg.parsedField directly
contract Example {
receive(msg: Sample) {
// Process msg.parsedField directly
}
}
```

Expand All @@ -138,13 +140,13 @@ receive(msg: Sample) {
Avoid parsing strings from human-readable formats into binary structures **on-chain**, as this increases computational overhead and gas costs.

```tact
message Sample {
field: String;
}
message Sample { field: String }

receive(msg: Sample) {
// Parsing occurs on-chain, which is inefficient
let parsed = field.fromBase64();
contract Example {
receive(msg: Sample) {
// Parsing occurs on-chain, which is inefficient
let parsed = field.fromBase64();
}
}
```

Expand All @@ -155,11 +157,9 @@ Be careful with the `Out of gas error`. It cannot be handled, so try to pre-calc
##### Do's ✅

```tact
message Vote {
votes: Int as int32;
}
message Vote { votes: Int as int32 }

contract Sample2 {
contract Example {
const voteGasUsage = 10000; // precompute with tests

receive(msg: Vote) {
Expand Down Expand Up @@ -360,7 +360,7 @@ Return excesses using a [Message][message] with `0xd53276db` opcode.

```tact
message(0xd53276db) Excesses {}
message Vote { votes: Int as int32; }
message Vote { votes: Int as int32 }

contract Sample {
votes: Int as uint32 = 0;
Expand All @@ -378,14 +378,11 @@ contract Sample {
}
```

Also, you can leverage [`notify():{tact}`](/ref/core-base/#self-notify) or [`forward():{tact}`](/ref/core-base/#self-forward) standard functions.
Also, you can leverage [`notify(){:tact}`](/ref/core-base/#self-notify) or [`forward(){:tact}`](/ref/core-base/#self-forward) standard functions.

```tact
message Vote {
votes: Int as int32;
}

message(0xd53276db) Excesses {}
message Vote { votes: Int as int32 }

contract Sample {
votes: Int as uint32 = 0;
Expand All @@ -409,12 +406,8 @@ Thus, any on-chain communication is asynchronous and done by sending and receivi
Exchange messages to pull data from other contract.

```tact
message ProvideMoney {
}

message TakeMoney {
money: Int as coins;
}
message ProvideMoney {}
message TakeMoney { money: Int as coins }

contract OneContract {
money: Int as coins;
Expand Down
Loading